From 0626b618ad0d3c5f8fbb6ab3facce440647fb3c0 Mon Sep 17 00:00:00 2001 From: Carles Barrobés Date: Sat, 25 Jun 2011 12:35:17 +0200 Subject: Support for HEAD method --- djangorestframework/compat.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'djangorestframework/compat.py') 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 -- cgit v1.2.3