django-formtools
django-formtools copied to clipboard
Make step url or get_step_url() available to templates
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:
- StepsHelper could return an object with a
step.url
property instead of requiring a manual{% url wizard.url_name step=step param1=param1.some.ref param2=param2.some.ref param3=param3.some.ref ...etc... %}
- The view could be passed into the context and a template filter could be offered that accepts the step as an argument and pulls the view from context to use
wizardview.get_step_url()
- A step url map could be passed into the template via context and a template filter could pull from there