Browse files

Fixed #22992 -- regression in .filter(generic_fk=...) error message

Generic Foreign Keys can't be used as lhs in lookups for historical
reasons. Django 1.6 gave a FieldDoesNotExist exception when using GFKs
as lhs in lookups, but due to regression caused by lookup refactor patch
(20bab2c) the exception type was
changed to AttributeError.

It might be a good idea to add support for gfk__exact and gfk__in lookups
later on.

Thanks to for the report. The code in this commit
was written by Tim Graham.
  • Loading branch information...
1 parent 9cd5201 commit efe87d3e48df9b7470a3006eeb7322f12b368fdf @akaariai akaariai committed with timgraham Jul 14, 2014
Showing with 4 additions and 0 deletions.
  1. +4 −0 tests/generic_relations/
@@ -355,6 +355,10 @@ def test_update_or_create_defaults(self):
+ def test_query_content_type(self):
+ with six.assertRaisesRegex(self, FieldError, "^Cannot resolve keyword 'content_object' into field."):
+ TaggedItem.objects.get(content_object='')
class CustomWidget(forms.TextInput):

0 comments on commit efe87d3

Please sign in to comment.