def method_required(method):
    """
    Decorator factory that limits a view to a particular HTTP method. 
    """
    from django.http import HttpResponseNotAllowed
    def _decorator(func):
        def _closure(request, *args, **kwargs):
            if not request.method==method:
                return HttpResponseNotAllowed([method])
            else:
                return func(request, *args, **kwargs)
        _closure.__name__ = func.__name__
        _closure.__doc___ = func.__doc__
        _closure.__module___ = func.__module__
        return _closure
    return _decorator