Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
14ded261
Commit
14ded261
authored
May 17, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PendingDeprecation warning to allow_empty
parent
2dd48fbb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
rest_framework/mixins.py
+7
-0
No files found.
rest_framework/mixins.py
View file @
14ded261
...
@@ -10,6 +10,7 @@ from django.http import Http404
...
@@ -10,6 +10,7 @@ from django.http import Http404
from
rest_framework
import
status
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.request
import
clone_request
from
rest_framework.request
import
clone_request
import
warnings
def
_get_validation_exclusions
(
obj
,
pk
=
None
,
slug_field
=
None
,
lookup_field
=
None
):
def
_get_validation_exclusions
(
obj
,
pk
=
None
,
slug_field
=
None
,
lookup_field
=
None
):
...
@@ -77,6 +78,12 @@ class ListModelMixin(object):
...
@@ -77,6 +78,12 @@ class ListModelMixin(object):
# Default is to allow empty querysets. This can be altered by setting
# Default is to allow empty querysets. This can be altered by setting
# `.allow_empty = False`, to raise 404 errors on empty querysets.
# `.allow_empty = False`, to raise 404 errors on empty querysets.
if
not
self
.
allow_empty
and
not
self
.
object_list
:
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__
class_name
=
self
.
__class__
.
__name__
error_msg
=
self
.
empty_error
%
{
'class_name'
:
class_name
}
error_msg
=
self
.
empty_error
%
{
'class_name'
:
class_name
}
raise
Http404
(
error_msg
)
raise
Http404
(
error_msg
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment