K
K
Konstantin Kruglov2016-08-20 11:18:34
Django
Konstantin Kruglov, 2016-08-20 11:18:34

How to correctly use proxy and manager?

In the proxy, you can implement sorting functionality, which is inappropriate to apply to the parent model in cases where there is a lot of data and sorting will "slow down". Well, I took it straight from the documentation. But it looks healthy. Another proxy is convenient to reassign the default manager. In this case, the parent model remains untouched.
In the proxy and the manager, you can implement the same thing in the form of methods for saving the model, issuing data, deleting, updating. The only difference will be what will be called, the model itself or the proxy model (it's even nicer if you call a proxy, you don't need to specify a manager).
In general, the differences are not significant. At first sight. Surely there is some practice of using both.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question