When defining a FormView derived class:
class PrefsView(FormView):
template_name = "prefs.html"
form_class = MyForm # What's wrong with this?
def get(self,request):
context = self.get_context_data()
context['pagetitle'] = 'My special Title'
context['form'] = MyForm # Why Do I have to write this?
return render(self.request,self.template_name,context)
I expected the line context['form'] = MyForm
was not needed, since form_class
is defined, but without it {{ form }}
is not passed to template.
What I'm doing wrong?