aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/mixins.py
diff options
context:
space:
mode:
authorTom Christie2013-05-17 21:28:33 +0100
committerTom Christie2013-05-17 21:28:33 +0100
commit14ded26167b68aaf8316a6bf83b6be3e77c8bbd8 (patch)
treed3ac1a4ae9e59d5074ee71b702e56a0001947dfb /rest_framework/mixins.py
parent2dd48fbb05ac6fc4e0d2327ac24ec5c3ae8e1e3e (diff)
downloaddjango-rest-framework-14ded26167b68aaf8316a6bf83b6be3e77c8bbd8.tar.bz2
PendingDeprecation warning to allow_empty
Diffstat (limited to 'rest_framework/mixins.py')
-rw-r--r--rest_framework/mixins.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py
index ae703771..55d21a70 100644
--- a/rest_framework/mixins.py
+++ b/rest_framework/mixins.py
@@ -10,6 +10,7 @@ from django.http import Http404
from rest_framework import status
from rest_framework.response import Response
from rest_framework.request import clone_request
+import warnings
def _get_validation_exclusions(obj, pk=None, slug_field=None, lookup_field=None):
@@ -77,6 +78,12 @@ class ListModelMixin(object):
# Default is to allow empty querysets. This can be altered by setting
# `.allow_empty = False`, to raise 404 errors on empty querysets.
if not self.allow_empty and not self.object_list:
+ warnings.warn(
+ 'The `allow_empty` parameter is due to be deprecated. '
+ 'To use `allow_empty=False` style behavior, You should override '
+ '`get_queryset()` and explicitly raise a 404 on empty querysets.',
+ PendingDeprecationWarning
+ )
class_name = self.__class__.__name__
error_msg = self.empty_error % {'class_name': class_name}
raise Http404(error_msg)