Django: How To Provide Context For A Formview?
Newbie Question: I have a FormView which displays a sign-up form, using Django's validations, etc. It all works fine, however, I can't seem to work out how to provide any data (con
Solution 1:
You have to methods of doing it, if the data is related only to that get view then you can move on:
defget_context_data(self, **kwargs):
context = super(SignUpView, self).get_context_data(**kwargs)
something = something
context['something'] = something
return context
Or use a Mixin:
classSomeMixin(object):defget_context_data(self, **kwargs):
context = super(SomeMixin, self).get_context_data(**kwargs)
something = something
context['something'] = something
return context
And then:
classSignUpView(SomeMixin, FormView):defform_valid(self, form):
...
Post a Comment for "Django: How To Provide Context For A Formview?"