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
2cc4cb24
Commit
2cc4cb24
authored
Jan 31, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error text in test.
parent
6838f173
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
docs/topics/3.1-announcement.md
+3
-1
rest_framework/views.py
+5
-2
tests/test_generics.py
+1
-1
No files found.
docs/topics/3.1-announcement.md
View file @
2cc4cb24
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#### Pagination controls in the browsable API.
#### Pagination controls in the browsable API.
#### New
pagination schemes
.
#### New
schemes, including cursor pagination
.
#### Support for header-based pagination.
#### Support for header-based pagination.
...
@@ -12,4 +12,6 @@
...
@@ -12,4 +12,6 @@
## Internationalization
## Internationalization
## New fields
## ModelSerializer API
## ModelSerializer API
rest_framework/views.py
View file @
2cc4cb24
...
@@ -4,6 +4,7 @@ Provides an APIView class that is the base of all views in REST framework.
...
@@ -4,6 +4,7 @@ Provides an APIView class that is the base of all views in REST framework.
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.http
import
Http404
from
django.utils
import
six
from
django.utils.encoding
import
smart_text
from
django.utils.encoding
import
smart_text
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
...
@@ -74,11 +75,13 @@ def exception_handler(exc, context):
...
@@ -74,11 +75,13 @@ def exception_handler(exc, context):
return
Response
(
data
,
status
=
exc
.
status_code
,
headers
=
headers
)
return
Response
(
data
,
status
=
exc
.
status_code
,
headers
=
headers
)
elif
isinstance
(
exc
,
Http404
):
elif
isinstance
(
exc
,
Http404
):
data
=
{
'detail'
:
_
(
'Not found.'
)}
msg
=
_
(
'Not found.'
)
data
=
{
'detail'
:
six
.
text_type
(
msg
)}
return
Response
(
data
,
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
data
,
status
=
status
.
HTTP_404_NOT_FOUND
)
elif
isinstance
(
exc
,
PermissionDenied
):
elif
isinstance
(
exc
,
PermissionDenied
):
data
=
{
'detail'
:
_
(
'Permission denied.'
)}
msg
=
_
(
'Permission denied.'
)
data
=
{
'detail'
:
six
.
text_type
(
msg
)}
return
Response
(
data
,
status
=
status
.
HTTP_403_FORBIDDEN
)
return
Response
(
data
,
status
=
status
.
HTTP_403_FORBIDDEN
)
# Note: Unhandled exceptions will raise a 500 error.
# Note: Unhandled exceptions will raise a 500 error.
...
...
tests/test_generics.py
View file @
2cc4cb24
...
@@ -483,7 +483,7 @@ class TestFilterBackendAppliedToViews(TestCase):
...
@@ -483,7 +483,7 @@ class TestFilterBackendAppliedToViews(TestCase):
request
=
factory
.
get
(
'/1'
)
request
=
factory
.
get
(
'/1'
)
response
=
instance_view
(
request
,
pk
=
1
)
.
render
()
response
=
instance_view
(
request
,
pk
=
1
)
.
render
()
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertEqual
(
response
.
data
,
{
'detail'
:
'Not found'
})
self
.
assertEqual
(
response
.
data
,
{
'detail'
:
'Not found
.
'
})
def
test_get_instance_view_will_return_single_object_when_filter_does_not_exclude_it
(
self
):
def
test_get_instance_view_will_return_single_object_when_filter_does_not_exclude_it
(
self
):
"""
"""
...
...
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