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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -