aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2014-09-10 16:57:22 +0100
committerTom Christie2014-09-10 16:57:22 +0100
commit80ba0473473501968154c5cc5dd5922e53d96a70 (patch)
tree40e766f9f2149a5f9052465ff22ad07b161ae905 /rest_framework/compat.py
parent01c8c0cad977fc0787dbfc78bd34f4fd37e613f4 (diff)
downloaddjango-rest-framework-80ba0473473501968154c5cc5dd5922e53d96a70.tar.bz2
Compat fixes
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index 70b38df9..7c05bed9 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -110,8 +110,18 @@ def get_concrete_model(model_cls):
return model_cls
+# View._allowed_methods only present from 1.5 onwards
+if django.VERSION >= (1, 5):
+ from django.views.generic import View
+else:
+ from django.views.generic import View as DjangoView
+
+ class View(DjangoView):
+ def _allowed_methods(self):
+ return [m.upper() for m in self.http_method_names if hasattr(self, m)]
+
+
# PATCH method is not implemented by Django
-from django.views.generic import View
if 'patch' not in View.http_method_names:
View.http_method_names = View.http_method_names + ['patch']