#31390: Using Q as rhs value in filter causes SQL Syntax error
-------------------------------------+-------------------------------------
Reporter: Marcin Wieczorek | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: Q filter SQL | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* status: new => closed
* resolution: => invalid
Comment:
> Using Q as rhs value in filter...
Sorry, this is just a misuse of `Q`. A `Q` represents the expression, not
just the rhs (or lhs).
Look at [https://docs.djangoproject.com/en/3.0/topics/db/queries/#complex-
lookups-with-q the examples from the docs]:
`Q(question__startswith='What')`.
So in your case you need `A.objects.filter(Q())` (not `pk=Q()`)
Please use support channels if you have further queries.
--
Ticket URL: <https://code.djangoproject.com/ticket/31390#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/073.60522908fd8d30b2a099bed878400075%40djangoproject.com.