Created
September 23, 2015 16:47
-
-
Save alexkahn/4075934201a5a86c4224 to your computer and use it in GitHub Desktop.
pass a query param to a form
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 .forms import AccountCreationForm | |
class IndexView(TemplateView): | |
template_name = 'myapp/mytemplate.html' | |
def get_context_data(self, **kwargs): | |
ctx = super(IndexView, self).get_context_data(**kwargs) | |
# you can use any query param key you'd like... | |
ctx['form'] = AccountCreationForm(initial={'promotion_code': self.request.GET.get('c', '')}) | |
return ctx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment