Last active
December 20, 2016 18:57
-
-
Save patrys/63cb08ec0363267011739fa28296179a 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.template.response import TemplateResponse | |
from django.views.generic import View | |
class MyClassBasedView(View): | |
def __init__(self, foo='bar'): | |
self._foo = foo | |
def get(self, request): | |
context = {'foo': self._foo} | |
return TemplateResponse(request, 'index.html', context) | |
my_class_based_view = MyClassBasedView.as_view(foo='bar') | |
# TypeError: MyClassBasedView() received an invalid keyword 'foo'. | |
# as_view only accepts arguments that are already attributes of the class. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment