Django subquery using QuerySet

Is it possible to subquery a QuerySet using another QuerySet?

For instance:

q = Something.objects.filter(x=y).extra(where=query_set2)
+3
source share
2 answers

Short answer: None. extraThe method does not wait for the transfer of requests.

If you think about it a little, it makes sense. Querysets is an abstraction used to represent the results of a fetch operation in a database, and extrais a convenient way to bind custom fields from a database to a set of queries. If you do not change the fundamental nature of extraโ€œuser filtering using a different set of queriesโ€, this will not work.

+6

.

  • , :

    q = Something.objects.filter(x=y, w=z)
    
  • "" SQL. Django, . Django.

+2

Source: https://habr.com/ru/post/1765997/


All Articles