summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2014-07-14 15:02:00 +0300
committerTim Graham <timograham@gmail.com>2014-07-14 12:55:05 -0400
commit4b53bfff3714d1f6f0f830d56fff296fb57b21da (patch)
tree2f52dce2fe63bfd2fd0c0a0b3806ed449a7ae30a
parent572885729e028eae2f2b823ef87543b7c66bdb10 (diff)
[1.7.x] 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. Backport of efe87d3e48 from master
-rw-r--r--tests/generic_relations/tests.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py
index ae90ace34a..3e05bb7225 100644
--- a/tests/generic_relations/tests.py
+++ b/tests/generic_relations/tests.py
@@ -304,6 +304,10 @@ class GenericRelationsTests(TestCase):
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