Commit bdeb2894 by Tom Christie

Use RuntimeError, not AssertionError when guarding against direct View.queryset…

Use RuntimeError, not AssertionError when guarding against direct View.queryset evalutation. Refs #3180.
parent 36d8d368
......@@ -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.'
......
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment