#28315: Support an API for filtering of GenericForeignKeys
-------------------------------------+-------------------------------------
Reporter: MichaĆ | Owner: nobody
Pasternak |
Type: New | Status: new
feature |
Component: Database | Version: 1.11
layer (models, ORM) | Keywords: generic foreign
Severity: Normal | keys content types filtering
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi,
just to let you know, my project that allows filtering of
GenericForeignKeys called "djorm-ext-filtered-contenttypes" supports
Django versions 1.8-1.11 on Python 2.7, 3.5 and 3.6.
{{{#!python
class Foo(models.Model):
a = GenericForeignKey()
Foo.objects.filter(a__in=[ThisModel, OtherModel, AnotherModel])
}}}
My package relies on PostgreSQL and allows to efficiently filter
GenericForeignKeys using server-side SQL which looks like:
{{{#!python
SELECT ... FROM ... WHERE (t0.content_type_id, t0.object_id) IN (....)
}}}
If you add a compound index on t0(content_type_id, object_id)... speed and
efficiency.
Check it out: https://github.com/mpasternak/djorm-ext-filtered-
contenttypes . If there is any interest from core developers, I'm willing
to submit a high-quality patch to the main branch, probably living
somewhere below contrib.postgresql
--
Ticket URL: <https://code.djangoproject.com/ticket/28315>
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/053.663e4a436c6274f8a04961bebab6d211%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.