﻿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
24002	.filter(generic_rel=val) should filter on related model primary key value, not the object_id value	Anssi Kääriäinen	nobody	"Doing `Publisher.objects.filter(book=1)` currently produces a query with `WHERE book.object_id = 1` (assuming book is GenericRelation field). That is, the filter targets object_id field of book. Filtering on reverse side of a foreign key relation does however target the primary key field of the related model. Similarly aggregating over generic relation targets the object_id field, not the primary key field.

The most problematic case is doing a query like `Publisher.objects.filter(book=somebook.pk)`. This doesn't work correctly with generic relations, but works nicely with reverse foreign key relations.

Unfortunately fixing this changes behavior of currently working code, and I can't think of any sensible way to do this with backwards compatibility period. So, I suggest we just treat this as a bug fix for master.

"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed			Accepted	1	0	0	0	0	0
