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
910de38a
Commit
910de38a
authored
Dec 06, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.3.10
parent
85d9eb0f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
2 deletions
+77
-2
docs/api-guide/status-codes.md
+21
-0
docs/topics/release-notes.md
+4
-1
rest_framework/__init__.py
+1
-1
rest_framework/status.py
+17
-0
rest_framework/tests/test_status.py
+34
-0
No files found.
docs/api-guide/status-codes.md
View file @
910de38a
...
@@ -17,6 +17,18 @@ Using bare status codes in your responses isn't recommended. REST framework inc
...
@@ -17,6 +17,18 @@ Using bare status codes in your responses isn't recommended. REST framework inc
The full set of HTTP status codes included in the
`status`
module is listed below.
The full set of HTTP status codes included in the
`status`
module is listed below.
The module also includes a set of helper functions for testing if a status code is in a given range.
from rest_framework import status
from rest_framework.test import APITestCase
class ExampleTestCase(APITestCase):
def test_url_root(self):
url = reverse('index')
response = self.client.get(url)
self.assertTrue(status.is_success(response.status_code))
For more information on proper usage of HTTP status codes see
[
RFC 2616
][
rfc2616
]
For more information on proper usage of HTTP status codes see
[
RFC 2616
][
rfc2616
]
and
[
RFC 6585
][
rfc6585
]
.
and
[
RFC 6585
][
rfc6585
]
.
...
@@ -90,6 +102,15 @@ Response status codes beginning with the digit "5" indicate cases in which the s
...
@@ -90,6 +102,15 @@ Response status codes beginning with the digit "5" indicate cases in which the s
HTTP_505_HTTP_VERSION_NOT_SUPPORTED
HTTP_505_HTTP_VERSION_NOT_SUPPORTED
HTTP_511_NETWORK_AUTHENTICATION_REQUIRED
HTTP_511_NETWORK_AUTHENTICATION_REQUIRED
## Helper functions
The following helper functions are available for identifying the category of the response code.
is_informational() # 1xx
is_success() # 2xx
is_redirect() # 3xx
is_client_error() # 4xx
is_server_error() # 5xx
[
rfc2324
]:
http://www.ietf.org/rfc/rfc2324.txt
[
rfc2324
]:
http://www.ietf.org/rfc/rfc2324.txt
[
rfc2616
]:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
[
rfc2616
]:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
...
...
docs/topics/release-notes.md
View file @
910de38a
...
@@ -40,10 +40,13 @@ You can determine your currently installed version using `pip freeze`:
...
@@ -40,10 +40,13 @@ You can determine your currently installed version using `pip freeze`:
## 2.3.x series
## 2.3.x series
### Master
### 2.3.10
*
*Date
**
:
6th December 2013
*
Add in choices information for ChoiceFields in response to `OPTIONS` requests.
*
Add in choices information for ChoiceFields in response to `OPTIONS` requests.
*
Added `pre_delete()` and `post_delete()` method hooks.
*
Added `pre_delete()` and `post_delete()` method hooks.
*
Added status code category helper functions.
*
Bugfix
:
Partial updates which erronously set a related field to `None` now correctly fail validation instead of raising an exception.
*
Bugfix
:
Partial updates which erronously set a related field to `None` now correctly fail validation instead of raising an exception.
*
Bugfix
:
Responses without any content no longer include an HTTP `'Content-Type'` header.
*
Bugfix
:
Responses without any content no longer include an HTTP `'Content-Type'` header.
*
Bugfix
:
Correctly handle validation errors in PUT-as-create case, responding with 400.
*
Bugfix
:
Correctly handle validation errors in PUT-as-create case, responding with 400.
...
...
rest_framework/__init__.py
View file @
910de38a
...
@@ -8,7 +8,7 @@ ______ _____ _____ _____ __ _
...
@@ -8,7 +8,7 @@ ______ _____ _____ _____ __ _
"""
"""
__title__
=
'Django REST framework'
__title__
=
'Django REST framework'
__version__
=
'2.3.
9
'
__version__
=
'2.3.
10
'
__author__
=
'Tom Christie'
__author__
=
'Tom Christie'
__license__
=
'BSD 2-Clause'
__license__
=
'BSD 2-Clause'
__copyright__
=
'Copyright 2011-2013 Tom Christie'
__copyright__
=
'Copyright 2011-2013 Tom Christie'
...
...
rest_framework/status.py
View file @
910de38a
...
@@ -6,6 +6,23 @@ And RFC 6585 - http://tools.ietf.org/html/rfc6585
...
@@ -6,6 +6,23 @@ And RFC 6585 - http://tools.ietf.org/html/rfc6585
"""
"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
def
is_informational
(
code
):
return
code
>=
100
and
code
<=
199
def
is_success
(
code
):
return
code
>=
200
and
code
<=
299
def
is_redirect
(
code
):
return
code
>=
300
and
code
<=
399
def
is_client_error
(
code
):
return
code
>=
400
and
code
<=
499
def
is_server_error
(
code
):
return
code
>=
500
and
code
<=
599
HTTP_100_CONTINUE
=
100
HTTP_100_CONTINUE
=
100
HTTP_101_SWITCHING_PROTOCOLS
=
101
HTTP_101_SWITCHING_PROTOCOLS
=
101
HTTP_200_OK
=
200
HTTP_200_OK
=
200
...
...
rest_framework/tests/test_status.py
0 → 100644
View file @
910de38a
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.status
import
(
is_informational
,
is_success
,
is_redirect
,
is_client_error
,
is_server_error
)
class
TestStatus
(
TestCase
):
def
test_status_categories
(
self
):
self
.
assertFalse
(
is_informational
(
99
))
self
.
assertTrue
(
is_informational
(
100
))
self
.
assertTrue
(
is_informational
(
199
))
self
.
assertFalse
(
is_informational
(
200
))
self
.
assertFalse
(
is_success
(
199
))
self
.
assertTrue
(
is_success
(
200
))
self
.
assertTrue
(
is_success
(
299
))
self
.
assertFalse
(
is_success
(
300
))
self
.
assertFalse
(
is_redirect
(
299
))
self
.
assertTrue
(
is_redirect
(
300
))
self
.
assertTrue
(
is_redirect
(
399
))
self
.
assertFalse
(
is_redirect
(
400
))
self
.
assertFalse
(
is_client_error
(
399
))
self
.
assertTrue
(
is_client_error
(
400
))
self
.
assertTrue
(
is_client_error
(
499
))
self
.
assertFalse
(
is_client_error
(
500
))
self
.
assertFalse
(
is_server_error
(
499
))
self
.
assertTrue
(
is_server_error
(
500
))
self
.
assertTrue
(
is_server_error
(
599
))
self
.
assertFalse
(
is_server_error
(
600
))
\ No newline at end of file
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