Created
November 13, 2012 11:00
-
-
Save roxeteer/4065214 to your computer and use it in GitHub Desktop.
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 import TemplateView | |
class ClassView(TemplateView): | |
template_name = "custom_view.html" | |
def get_context_data(self, **kwargs): | |
# This allows this View to be easily subclassed in the future to interchange context data. | |
context = kwargs | |
return context | |
def dispatch(self, request, *args, **kwargs): | |
# Do something fancy here. | |
return super(ClassView, self).dispatch(request, *args, **kwargs) | |
def get(self, request, *args, **kwargs): | |
# Do something with GET. | |
context = self.get_context_data(**kwargs) | |
return self.render_to_response(context) | |
def post(self, request, *args, **kwargs): | |
# Do something with the POST data. | |
context = self.get_context_data(**kwargs) | |
return self.render_to_response(context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment