I have a class QuestionView which is derived from the FormView class. Here
is a code snippet to explain my problem:
class QuestionView(FormView):
...
context_var1 = y
def form_valid (self, form):
...
self.context_var1 = x
...
def get_context_data(self, **kwargs):
...
context['context_var1'] = self.context_var1
...
return context
As shown above, I update a set of context variables in form_valid and
I intend to use the updated values of these in the template - hence the variables in the context dictionary. The problem with this code is that the change in
context_var1 isn't seen - might be because get_context_data is
called before the form_valid method. Is there is a workaround for
this?