Skip to content

Commit

Permalink
Tested QuerySet compatibility check.
Browse files Browse the repository at this point in the history
cdfdcf4 missed this test.
  • Loading branch information
timgraham committed Oct 14, 2016
1 parent 9108696 commit b679a3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/models/sql/query.py
Expand Up @@ -1059,7 +1059,7 @@ def check_related_objects(self, field, value, opts):
if not value.is_compatible_query_object_type(opts, field):
raise ValueError(
'Cannot use QuerySet for "%s": Use a QuerySet for "%s".' %
(value.model._meta.model_name, opts.object_name)
(value.model._meta.object_name, opts.object_name)
)
elif hasattr(value, '_meta'):
self.check_query_object_type(value, opts, field)
Expand Down
5 changes: 5 additions & 0 deletions tests/queries/tests.py
Expand Up @@ -2969,6 +2969,11 @@ def test_invalid_order_by(self):
with self.assertRaisesMessage(FieldError, msg):
list(Article.objects.order_by('*'))

def test_invalid_queryset_model(self):
msg = 'Cannot use QuerySet for "Article": Use a QuerySet for "ExtraInfo".'
with self.assertRaisesMessage(ValueError, msg):
list(Author.objects.filter(extra=Article.objects.all()))


class NullJoinPromotionOrTest(TestCase):
@classmethod
Expand Down

0 comments on commit b679a3c

Please sign in to comment.