Monday, August 1, 2011

Re: Updating Context Data in FormView 'form_valid' Method

Thanks much for the replies.


> As shown above, I update a set of context variables in form_valid and
> I intend to use these in the template - hence the variables in 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 'form_valid' method. Is there is a work around for
> this?

Well, you've got to call the functions in the appropriate order. Try
accessing the attribute via self, and see where that gets you.


I tried accessing via self as well. Even that isn't solving my problem. 
To make this work, the OP needs to assign to `self.context_var1` in the `__init__  method.
Could you please explain this in more detail?

Regards.
Abhilash I.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment