jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
784 stars 135 forks source link

Make step url or get_step_url() available to templates #273

Open thenewguy opened 3 months ago

thenewguy commented 3 months ago

It is complicated to generate step urls for wizard navigation in a reusable fashion while iterating {% for step in wizard.steps.all %} in templates for wizards that implement a custom get_step_url() method . The url reversal can require extra references and to complicate matters further, these references might not be available to the template.

One can work around this by adding extra context variables for the template to use, but this isn't very DRY when the wizard already knows how to reverse its urls with just a step name.

It would be helpful if the value from WizardView.get_step_url(step) was available to the template.

A few approaches that come to mind: