What ready-made solutions exist for storing images to the product to the product catalog.
It is required either a ready-made minimal implementation example or an application with minimal functionality, monsters like oscar are not needed here.
Parsed options. One-to-one connection, json field, GenericRelation.
Disadvantages:
json - you have to do a lot
foreign key - a large number of requests
GenericRelation - requests, difficulty in understanding the code.
I would like to find the optimal solution, preferably ready to connect to the project.
Note
The proposed @FeroxTL solution through prefetch_related is both the most popular and the most optimal in terms of performance. In addition, there is always the possibility of speeding up through redundancy by copying data for output into an additional field in the product table.
Addition of the answer
select_related()
and there will be no more requests when using aForeignKey
. - Sergey Gornostaev