Python Django Form Wizard: How to implement cancel button -


i using form wizard , want implement cancel-button brings me page on clicked link brought me formwizard. there smart way this? @ moment adding redirect link starts form wizard that:

<td><a href="/lecture/add/?redirect={{ request.path }}">create new lecture</a></td> 

then in get_context_data add self.request.get.get('redirect') context. in template have cancel-button redirects link context. works in step 1. in other steps information gone. have idea how solve this? appreciated!

you might want use hidden input field transmit cancel action each time form submitted:

<input type="hidden" name="redirect" value="{{ cancel_action }}" /> 

and read in view:

def get_context_data(self, form, **kwargs):     # ...     if self.request.get.get('redirect'):         # ...     elif self.request.post.get('redirect'):         context.update({ 'cancel_action' : self.request.post.get('redirect') })     # ...     return context 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -