mirror of https://github.com/django/django.git
parent
9108696a75
commit
b679a3cdb1
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue