aboutsummaryrefslogtreecommitdiffstats
path: root/docs/topics/2.3-announcement.md
diff options
context:
space:
mode:
authorTom Christie2013-05-07 12:25:41 +0100
committerTom Christie2013-05-07 12:25:41 +0100
commitd71a5533f9a8787652244dfb16af37fb7d9059fb (patch)
tree9d7d4ad3e15a55d8a5e67c0888d91fd2f88edc61 /docs/topics/2.3-announcement.md
parentb70c9cc107743b45edc50c4b4e5e6a7d5a856f01 (diff)
downloaddjango-rest-framework-d71a5533f9a8787652244dfb16af37fb7d9059fb.tar.bz2
allow_empty -> pending deprecation in preference of overridden get_queryset.
Diffstat (limited to 'docs/topics/2.3-announcement.md')
-rw-r--r--docs/topics/2.3-announcement.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/docs/topics/2.3-announcement.md b/docs/topics/2.3-announcement.md
index c465b774..62fa5b9c 100644
--- a/docs/topics/2.3-announcement.md
+++ b/docs/topics/2.3-announcement.md
@@ -152,9 +152,21 @@ And would have the following entry in the urlconf:
url(r'^users/(?P<username>\w+)/$', UserDetail.as_view()),
-
Usage of the old-style attributes continues to be supported, but will raise a `PendingDeprecationWarning`.
+The `allow_empty` attribute is also deprecated. To use `allow_empty=False` style behavior you should explicitly override `get_queryset` and raise an `Http404` on empty querysets.
+
+For example:
+
+ class DisallowEmptyQuerysetMixin(object):
+ def get_queryset(self):
+ queryset = super(DisallowEmptyQuerysetMixin, self).get_queryset()
+ if not queryset.exists():
+ raise Http404
+ return queryset
+
+In our opinion removing lesser-used attributes like `allow_empty` helps us move towards simpler generic view implementations, making them more obvious to use and override, and re-inforcing the preferred style of developers writing their own base classes and mixins for custom behavior rather than relying on the configurability of the generic views.
+
## Simpler URL lookups
The `HyperlinkedRelatedField` class now takes a single optional `lookup_field` argument, that replaces the `pk_url_kwarg`, `slug_url_kwarg`, and `slug_field` arguments.