Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.7.x] Fixed #22992 -- regression in .filter(generic_fk=...) error m…

…essage

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 glicerinu@gmail.com for the report. The code in this commit
was written by Tim Graham.

Backport of efe87d3 from master
  • Loading branch information...
commit 4b53bfff3714d1f6f0f830d56fff296fb57b21da 1 parent 5728857
@akaariai akaariai authored timgraham committed
Showing with 4 additions and 0 deletions.
  1. +4 −0 tests/generic_relations/tests.py
View
4 tests/generic_relations/tests.py
@@ -304,6 +304,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
Please sign in to comment.
Something went wrong with that request. Please try again.