diff options
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 12 | 
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'] | 
