Reputation: 111
In my get_context_data method I create context variable only if certain conditions are met.
I want my form to be able to redirect different urls regarding that context variable is created or not.
How to access context['something'] in get_success_url method? Or is it possible?
Upvotes: 0
Views: 1079
Reputation: 599450
get_context_data
won't even be called if the form is valid, because a redirect needs no context. You should put that calculation somewhere else, perhaps into a separate method which could be called both from get_context_data
and form_valid
.
Upvotes: 1