Created
January 19, 2012 21:54
-
-
Save valyagolev/1643096 to your computer and use it in GitHub Desktop.
a view which dispatches requests to it to different views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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