Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:13:21+00:00 2026-06-06T10:13:21+00:00

At the moment I’m experimenting with django form wizard. The basic set-up works now

  • 0

At the moment I’m experimenting with django form wizard. The basic set-up works now and I’m able to call different templates for each step showing variable text.

Now I want to take it a step further and create a customized form layout for each step. The documentation of Django shows a generic way to show the form, always with vertical alignment.

In my experiment I have two steps:

  • step 1: email and password (just two fields needing vertical alignment)
  • step 2: personal data: address, profession, …

So for the step 2 I want to use a complete different form layout then step 1: using fieldsets, horizontal alignment of field (eg address: street and number), …

Starting from the django documentation I suppose that the below can work (did not test it yet):

{% block content %}
# block step: variable text for each step
{% block step %}{% endblock %}
<p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p>
<form action="" method="post">{% csrf_token %}
<table>
{{ wizard.management_form }}
{% if wizard.form.forms %}
    {{ wizard.form.management_form }}
    {% for form in wizard.form.forms %}
        # block form_if: shows a complete customized form layout for each step
        {% block form_if %}{% endblock %}
    {% endfor %}
{% else %}
    # block form_else: shows a complete customized form layout for each step
    {% block form_else %}{% endblock %}
{% endif %}
</table>
{% if wizard.steps.prev %}
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans    "first step" %}</button>
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
{% endif %}
<input type="submit" value="{% trans "submit" %}"/>
</form>
{% endblock %}

But the problem I have here is that I have two blocks: form_if and form_else calling the same form layout. So then I have double maintenance of my form layout.

Are there better ways to accomplish what I want to achieve?

Thanks!

Kind Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:13:23+00:00Added an answer on June 6, 2026 at 10:13 am

    Based on the input of Rohan and following post, I found a working solution:

    my base_wizard template looks as follows:

    <form enctype="multipart/form-data" action="" method="post">{% csrf_token %}
        <table>
            {{ wizard.management_form }}
            {% if wizard.form.forms %}
                {{ wizard.form.management_form }}
                {% for form in wizard.form.forms %}
                    <!-- block below accesses a customized form layout for each step -->
                    {% block form_if %}{% endblock %}
                {% endfor %}
            {% else %}
                <!-- block below accesses a customized form layout for each step -->
                <!-- using the with statement makes it possible to use the same layout used in the form_if block -->
                {% with form=wizard.form %}
                {% block form_else %}{% endblock %}
                {% endwith %}
            {% endif %}
        </table>
        {% if wizard.steps.prev %}
        <button name="wizard_goto_step" value="{{ wizard.steps.first }}" class="button">{% trans "first step" %}</button>
        <button name="wizard_goto_step" value="{{ wizard.steps.prev }}" class="button">{% trans "prev step" %}</button>
        {% endif %}
        <div>
            <input type="submit" value="{% trans "submit" %}" class="button"/>
        </div>  
    </form>
    

    and in the template per step I use following code:

    {% extends "base_wizard.html" %}
    
    {% block form_if %}{% block form_else %}
        <fieldset>
            <legend>Title</legend>
            <div>
                <label>{{ form.field.label }}:<p class="note">{{ form.field.help_text }}</p></label> {{ form.field }}
                <p class="error">
                    {% if form.field.errors %}
                        {% for error in form.field.errors %}
                            {{ error }}
                        {% endfor %}
                    {% endif %}
                </p>
            </div>
        </fieldset>
    {% endblock %}{% endblock %}
    

    Using this makes it possible to maintain just one form layout per step instead of two.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I am able to set the encryption key for my local
At the moment I'm using bat file to launch my jar and set the
At the moment I am trying to validate a form using PHP. The problem
At the moment I am using this to call the TabHost activity to change
At the moment i'm overriding drawRect in a view in order to be able
At the moment I have a set of divs, generated dynamically by php and
At the moment I'm creating a DateTime for each month and formatting it to
For the moment, when I'm in a controller and that I want to call
At the moment I am only able to output this to a string, although
At moment I want to implement picture upload without using any plug-ins. My upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.