A
A
Alexey2017-06-25 04:49:58
Django
Alexey, 2017-06-25 04:49:58

How to organize a model to hold a Django product size table?

I'm building a store with Django. The store has categories: Shoes, shirts, underpants, etc. Each category has its own size parameters: for shoes - foot length, for shirts - bust, waist, sleeve length, for pants - hip and waist. Therefore, in the category model, you need to somehow organize the input of the necessary dimensional parameters for the product, and in the product model, fill in this data and display it on the product page in the table as in the figure. GFphx.jpg
How to organize models correctly?
Tried to use EAV:
1. Category table.
2. Table Signs of Categories.
- foreign key to the Category;
3. Table of Significance Values.
- foreign key to FeatureCategories;
- foreign key to Goods;
- value
However, in this case, a flat list of values ​​is obtained for the product, for example:
Product shirt: sleeve length - 50 cm, chest girth - 50 cm, shoulder girth - 100 cm, and not a two-dimensional table with sizes.
The only understandable option I see is to use a table containing all the possible characteristics of the goods, and fill in only those that are needed for this product, and in the view select only the filled fields from the table for the desired product and transfer them to the template. But this is some kind of creepy monster, not a table, and when adding a new category, you will have to manually add new characteristics to the model.
Help, please, where to dig?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Kuts, 2017-06-25
@fox_12

If searching for these additional characteristics is not required, then as an option - JSONField or picklefield.
And there store any additional. characteristics.

A
alternativshik, 2017-06-25
@alternativshik

Goods - Sizes - Sizes have some measurements that relate to this type of goods (for a shirt, length, volume, for shoes, the length of the insole, etc.)

M
mr_drinkens89, 2017-11-13
@mr_drinkens89

Faced a similar problem.
Can you tell me which solution you ended up choosing?
Thank you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question