Skip to content

Instantly share code, notes, and snippets.

@valyagolev
Created January 19, 2012 21:54
Show Gist options
  • Save valyagolev/1643096 to your computer and use it in GitHub Desktop.
Save valyagolev/1643096 to your computer and use it in GitHub Desktop.
a view which dispatches requests to it to different views
from django.views.generic.base import View
class HttpMethodDependedView(View):
routes = {
}
def dispatch(self, request, *args, **kwargs):
method = request.method.lower()
if method in self.routes:
return self.routes[method](request, *args, **kwargs)
else:
self.request = request
self.args = args
self.kwargs = kwargs
return self.http_method_not_allowed(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment