From 14ded26167b68aaf8316a6bf83b6be3e77c8bbd8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 17 May 2013 21:28:33 +0100 Subject: [PATCH] PendingDeprecation warning to allow_empty --- rest_framework/mixins.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index ae703771d..55d21a706 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)