From efe87d3e48df9b7470a3006eeb7322f12b368fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Mon, 14 Jul 2014 15:02:00 +0300 Subject: [PATCH] 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 (20bab2cf9d02a5c6477d8aac066a635986e0d3f3) 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 glicerinu@gmail.com for the report. The code in this commit was written by Tim Graham. --- tests/generic_relations/tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py index ed74eb59a5c77..38077df7c32ce 100644 --- a/tests/generic_relations/tests.py +++ b/tests/generic_relations/tests.py @@ -355,6 +355,10 @@ def test_update_or_create_defaults(self): self.assertFalse(created) self.assertEqual(tag.content_object.id, diamond.id) + 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): pass