Tested QuerySet compatibility check.

cdfdcf4b70 missed this test.
This commit is contained in:
Tim Graham 2016-10-14 08:48:50 -04:00
parent 9108696a75
commit b679a3cdb1
2 changed files with 6 additions and 1 deletions

View File

@ -1059,7 +1059,7 @@ class Query(object):
if not value.is_compatible_query_object_type(opts, field): if not value.is_compatible_query_object_type(opts, field):
raise ValueError( raise ValueError(
'Cannot use QuerySet for "%s": Use a QuerySet for "%s".' % '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'): elif hasattr(value, '_meta'):
self.check_query_object_type(value, opts, field) self.check_query_object_type(value, opts, field)

View File

@ -2969,6 +2969,11 @@ class QuerySetExceptionTests(TestCase):
with self.assertRaisesMessage(FieldError, msg): with self.assertRaisesMessage(FieldError, msg):
list(Article.objects.order_by('*')) 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): class NullJoinPromotionOrTest(TestCase):
@classmethod @classmethod