Skip to content

Instantly share code, notes, and snippets.

@mvasilkov mvasilkov/
Created Jan 27, 2012

What would you like to do?
RestfulView from libanimuchan
from django.shortcuts import render
class RestfulView(object):
allowed_methods = ["GET", "POST"]
def __call__(self, request, *args, **kwargs):
if request.method not in self.allowed_methods or not hasattr(self, request.method):
return self.method_not_allowed(request)
return getattr(self, request.method)(request, *args, **kwargs)
def method_not_allowed(self, request):
return render(request, "405.html", status=405)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.