#29555: Left outer join with extra condition
-------------------------------------+-------------------------------------
Reporter: Enric Calabuig | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Queryset.extra | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Hello Enric,
Since the introduction of `FilteredRelation`
[https://docs.djangoproject.com/en/2.0/ref/models/querysets
/#filteredrelation-objects in Django 2.0] you should be able to achieved
exactly what you're after with the following
{{{#!python
Track.objects.annotate(
has_tag=FilteredRelation('trackhastag',
condition=Q(trackhastag__tag=1)),
).filter(
has_tag__isnull=True,
)
}}}
I'll mark this ticket as ''invalid'' for now but feel free to re-open it
if it doesn't match your use case of `extra()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/29555#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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.e8b75e0a0ef39a4b16ef85a183fb82e4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.