  
  except ImportError:
      from django import http
      from django.utils.functional import update_wrapper
      # from django.utils.log import getLogger
      # from django.utils.decorators import classonlymethod
  
      # logger = getLogger('django.request') - We'll just drop support for logger if running Django <= 1.2
      # Might be nice to fix this up sometime to allow rest_framework.compat.View to match 1.3's View more closely
  
      class View(object):
          """
          Intentionally simple parent class for all views. Only implements
          dispatch-by-method and simple sanity checking.
          """
  
          http_method_names = ['get', 'post', 'put', 'delete', 'head', 'options', 'trace']
  
          def __init__(self, **kwargs):
              """
 
</s> remove         http_method_names = ['get', 'post', 'put', 'delete', 'head', 'options', 'trace']

        def __init__(self, **kwargs):
            """
            Constructor. Called in the URLconf; can contain helpful extra
            keyword arguments, and other things.
            """
            # Go through keyword arguments, and either save their values to our
            # instance, or raise an error.
            for key, value in kwargs.iteritems():
                setattr(self, key, value)

        # @classonlymethod - We'll just us classmethod instead if running Django <= 1.2
        @classmethod
 </s> add     class View(_View):
        @classonlymethod </s> remove     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/15668
        class ViewPlusHead(View):
            def head(self, request, *args, **kwargs):
                return self.get(request, *args, **kwargs)
        View = ViewPlusHead

except ImportError:
    from django import http
 </s> add else:
    from django.views.generic import View as _View
    from django.utils.decorators import classonlymethod </s> remove # django.views.generic.View (Django >= 1.3)
try:
 </s> add # First implementation of Django class-based views did not include head method
# in base View class - https://code.djangoproject.com/ticket/15668
if django.VERSION >= (1, 4): </s> remove         def dispatch(self, request, *args, **kwargs):
            # Try to dispatch to the right method; if a method doesn't exist,
            # defer to the error handler. Also defer to the error handler if the
            # request method isn't on the approved list.
            if request.method.lower() in self.http_method_names:
                handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
            else:
                handler = self.http_method_not_allowed
            self.request = request
            self.args = args
            self.kwargs = kwargs
            return handler(request, *args, **kwargs)

        def http_method_not_allowed(self, request, *args, **kwargs):
            allowed_methods = [m for m in self.http_method_names if hasattr(self, m)]
            #logger.warning('Method Not Allowed (%s): %s' % (request.method, request.path),
            #    extra={
            #        'status_code': 405,
            #        'request': self.request
            #    }
            #)
            return http.HttpResponseNotAllowed(allowed_methods)

        def head(self, request, *args, **kwargs):
            return self.get(request, *args, **kwargs)

 </s> add 
  
  except ImportError:
      from django import http
      from django.utils.functional import update_wrapper











  
          http_method_names = ['get', 'post', 'put', 'delete', 'head', 'options', 'trace']
  
          def __init__(self, **kwargs):
              """
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 head method on views for Django 1.3.  Fixes #228 
rest_framework/compat.py