R
R
Rrooom2014-10-06 12:02:02
Django
Rrooom, 2014-10-06 12:02:02

Does django have a querybuilder?

More precisely, what he is - no doubt. But I can not find any documentation on how queries are built under the hood of the form. Is it possible to use querybuilder from the bowels of djanga and how?
The possibilities of the orm itself are no longer enough, you have to use raw Queries, which are already being converted into a separate querybuilder, which is not good.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Bukin, 2014-10-11
@abukin

Perhaps it is worth looking towards the QuerySet base class.
As an example of use - grouping:
query = Members.objects.all().query
query.group_by = ['designation']
results = QuerySet(query=query, model=Members)
It all depends on specific tasks, of course. Describe an example where ORM would not be enough to build functionality. In most cases, you can get by with them.
Well, you can always inherit this class by rewriting several methods at your discretion and using the already updated one, see the example above. Or build pure SQL and use cursor = connection.cursor() cursor.execute("SELECT foo FROM....") There's nothing wrong with that. It's even easier that way. The KISS principle must be respected. =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question