I
I
Igor2019-02-26 23:27:46
Django
Igor, 2019-02-26 23:27:46

How to work with Django models?

Good afternoon!
I am newbie. It is required to make a project for accounting things - who, when, what, if they took, and where they put it . The task is quite trivial, but this is my first project on the web and on Django.
Example: there are 10 nails for 50mm, a man came and took 5 nails. How many nails are left? - that is , the number of nails in one table has decreased, and an expense record has appeared in the other. Right?
It is necessary that each thing belongs to a separate genus (the genus nails, in the case of nails by 50), and that, in turn, belongs to another supergenus (building materials). And the whole joke is that each genus (supergenus) adds some additional property to the existing ones (length for the genus nails). It is obvious to me that I need to somehow do this with the help of descendants and parents, only then it is necessary to describe all the nails, screws, nuts in the models, and it is assumed that the genders change "on the go" (the user himself adds the "nails" gender and its properties ). How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-02-27
@Igorello74

This is done by model inheritance .

P
Pan Propan, 2019-02-27
@mgis

The easiest thing is to make 2 related models. Product (nails) Specification (length, thickness, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question