Multi-Table inheritance and Proxy models Part 8| #django in Deep

preview_player
Показать описание
The second type of model inheritance supported by #django django is when each model in the hierarchy is a model
all by itself. Each model corresponds to its own database table and can be queried and created individually. The #inheritance #relationship introduces links between the child model and each of its parents (via an
automatically-created #OneToOneField).

#proxy models

When using multi-table inheritance, a new database table is created for each subclass of a model. This is
usually the desired behavior, since the subclass needs a place to store any additional data fields that are not
present on the base class. Sometimes, however, you only want to change the Python behavior of a model –
perhaps to change the default manager, or add a new method.
This is what proxy model inheritance is for: creating a proxy for the original model. You can create, delete
and update instances of the proxy model and all the data will be saved as if you were using the original (non proxied) model. The difference is that you can change things like the default model ordering or the default
manager in the proxy, without having to alter the original.
Proxy models are declared like normal models. You tell Django that it’s a proxy model by setting the proxy
attribute of the Meta class to True
Рекомендации по теме
Комментарии
Автор

Thanks for all your content. Everything was useful for me. 👍👍👍

hojiakbarshirinov