Use RuntimeError, not AssertionError when guarding against direct View.queryset evalutation. Refs #3180.

This commit is contained in:
Tom Christie 2015-07-24 09:13:39 +01:00
parent 36d8d3681a
commit bdeb28944f
2 changed files with 2 additions and 2 deletions

View File

@ -121,7 +121,7 @@ class APIView(View):
"""
if isinstance(getattr(cls, 'queryset', None), models.query.QuerySet):
def force_evaluation():
raise AssertionError(
raise RuntimeError(
'Do not evaluate the `.queryset` attribute directly, '
'as the result will be cached and reused between requests. '
'Use `.all()` or call `.get_queryset()` instead.'

View File

@ -541,5 +541,5 @@ class TestGuardedQueryset(TestCase):
view = QuerysetAccessError.as_view()
request = factory.get('/')
with pytest.raises(AssertionError):
with pytest.raises(RuntimeError):
view(request).render()