I am trying to configure a proxy model in django admin. It will be a subset of the original model. Code from models.py:
class MyManager(models.Manager): def get_query_set(self): return super(MyManager, self).get_query_set().filter(some_column='value') class MyModel(OrigModel): objects = MyManager() class Meta: proxy = True
Now instead of filter () I need to use a complex SELECT statement with JOINS. How can I fully implement it in the user manager?
Django provides an extra () QuerySet modifier - this is the hook for entering certain sentences into SQL generated by the QuerySet.
This can be used in complex cases, possibly with one or more additional queries.
ORM MyModel.objects raw SQL . SQL .
- MyModel(). , .. admin, , , . , , , - raw sql get_query_set.
, Manager.raw admin.
Source: https://habr.com/ru/post/1749289/More articles:Run SQL queries in DataTables or similar in .Net without RDBMS - c #Open a new browser window in GWT containing the widget / panel - javaPHP displays progress messages on the fly - ajaxCalculate shared RAM used by Python dict or list - pythonHow to check crontab input? - shellКаков наилучший способ реализации потоковых разговоров, таких как Facebook Wall в .NET? - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1749291/force-vsprops-settings-to-override-project-settings&usg=ALkJrhiXEGgmlT-joSOPqlMSGzkXsq4vEQIs it possible to use the php header () command to call ajax to redirect? - redirectDrupal filter form input - drupalВызов функции PL/SQL, которая возвращает {Table}% ROWTYPE из С# - c#All Articles