Django form wizard save and go to previous step

后端 未结 2 1710
-上瘾入骨i
-上瘾入骨i 2021-01-01 07:07

I have a working django formwizard which when I hit the previous button doesn\'t validate the current input.

I\'ve tried variations on



        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 07:37

    One (arguably elegant) way would be to use a different POST variable than wizard_goto_step, and then override WizardView.get_next_step():

    def get_next_step(self, step=None):
        return self.request.POST.get('wizard_next_step',
                super().get_next_step(step))
    

    Then, use name="wizard_next_step" on the previous-step button/link. This approach both has the advantage that the old behavior remains available should you need it, and that you're not re-implementing WizardView.post().

提交回复
热议问题