﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28315	Support an API for filtering of GenericForeignKeys	Michał Pasternak	nobody	"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"	New feature	closed	Database layer (models, ORM)	1.11	Normal	duplicate	generic foreign keys content types filtering		Unreviewed	0	0	0	0	0	0
