diff options
| author | Carles Barrobés | 2011-06-25 12:35:17 +0200 |
|---|---|---|
| committer | Carles Barrobés | 2011-06-25 12:35:17 +0200 |
| commit | 0626b618ad0d3c5f8fbb6ab3facce440647fb3c0 (patch) | |
| tree | 516e67b1bfebd4e4dbb9fed4f3dc11fee0afde3a /djangorestframework/compat.py | |
| parent | fc1640de75511006e89f033c9270ec91a9f1e4d4 (diff) | |
| download | django-rest-framework-0626b618ad0d3c5f8fbb6ab3facce440647fb3c0.tar.bz2 | |
Support for HEAD method
Diffstat (limited to 'djangorestframework/compat.py')
| -rw-r--r-- | djangorestframework/compat.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/djangorestframework/compat.py b/djangorestframework/compat.py index 0274511a..f09b7cc3 100644 --- a/djangorestframework/compat.py +++ b/djangorestframework/compat.py @@ -67,6 +67,14 @@ except ImportError: # django.views.generic.View (Django >= 1.3) try: from django.views.generic import View + if not hasattr(View, 'head'): + # First implementation of Django class-based views did not include head method + # in base View class - https://code.djangoproject.com/ticket/15688 + class ViewPlusHead(View): + def head(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) + View = ViewPlusHead + except ImportError: from django import http from django.utils.functional import update_wrapper @@ -145,6 +153,8 @@ except ImportError: #) return http.HttpResponseNotAllowed(allowed_methods) + def head(self, request, *args, **kwargs): + return self.get(request, *args, **kwargs) try: import markdown @@ -193,4 +203,4 @@ try: return md.convert(text) except ImportError: - apply_markdown = None
\ No newline at end of file + apply_markdown = None |
