aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/status-codes.md
diff options
context:
space:
mode:
authorTom Christie2013-12-09 07:45:45 +0000
committerTom Christie2013-12-09 07:45:45 +0000
commit80ef2685e522fc87bd8af9767aa7b231c9991ea4 (patch)
tree4be3191af2eec42ffea97443c9e9f11ee5631ca7 /docs/api-guide/status-codes.md
parent4e9385e709bcee87456a99839841ecf6b56f337a (diff)
parent175b4d233d578b5964db72f91a96bb3b4a0f3e99 (diff)
downloaddjango-rest-framework-80ef2685e522fc87bd8af9767aa7b231c9991ea4.tar.bz2
Merge master
Diffstat (limited to 'docs/api-guide/status-codes.md')
-rw-r--r--docs/api-guide/status-codes.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/api-guide/status-codes.md b/docs/api-guide/status-codes.md
index 409f659b..64c46434 100644
--- a/docs/api-guide/status-codes.md
+++ b/docs/api-guide/status-codes.md
@@ -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 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]
and [RFC 6585][rfc6585].
@@ -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_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
[rfc2616]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html