Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #20478 – Added support for HTTP PATCH method in generic views.

  • Loading branch information...
commit ee8b810b977572e39dc6acf4d13cc5e05f4d65ee 1 parent 0e51d8e
Krzysztof Jurewicz authored May 21, 2013
5  django/views/generic/base.py
@@ -30,7 +30,7 @@ class View(object):
30 30
     dispatch-by-method and simple sanity checking.
31 31
     """
32 32
 
33  
-    http_method_names = ['get', 'post', 'put', 'delete', 'head', 'options', 'trace']
  33
+    http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']
34 34
 
35 35
     def __init__(self, **kwargs):
36 36
         """
@@ -206,3 +206,6 @@ def delete(self, request, *args, **kwargs):
206 206
 
207 207
     def put(self, request, *args, **kwargs):
208 208
         return self.get(request, *args, **kwargs)
  209
+
  210
+    def patch(self, request, *args, **kwargs):
  211
+        return self.get(request, *args, **kwargs)
2  docs/ref/class-based-views/base.txt
@@ -55,7 +55,7 @@ View
55 55
 
56 56
         Default::
57 57
 
58  
-            ['get', 'post', 'put', 'delete', 'head', 'options', 'trace']
  58
+            ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']
59 59
 
60 60
     **Methods**
61 61
 
3  docs/releases/1.6.txt
@@ -258,6 +258,9 @@ Minor features
258 258
   methods returning the first or last object matching the filters. Returns
259 259
   ``None`` if there are no objects matching.
260 260
 
  261
+* :class:`~django.views.generic.base.View` and
  262
+  :class:`~django.views.generic.base.RedirectView` now support HTTP PATCH method.
  263
+
261 264
 Backwards incompatible changes in 1.6
262 265
 =====================================
263 266
 
6  tests/generic_views/test_base.py
@@ -384,6 +384,12 @@ def test_redirect_PUT(self):
384 384
         self.assertEqual(response.status_code, 301)
385 385
         self.assertEqual(response.url, '/bar/')
386 386
 
  387
+    def test_redirect_PATCH(self):
  388
+        "Default is a permanent redirect"
  389
+        response = RedirectView.as_view(url='/bar/')(self.rf.patch('/foo/'))
  390
+        self.assertEqual(response.status_code, 301)
  391
+        self.assertEqual(response.url, '/bar/')
  392
+
387 393
     def test_redirect_DELETE(self):
388 394
         "Default is a permanent redirect"
389 395
         response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/'))

0 notes on commit ee8b810

Please sign in to comment.
Something went wrong with that request. Please try again.