Django multistep form

I have a multi-step form that is 3 steps but it has 4 forms. In the first form, the user has to choose from two choices. The user’s first form choices will determine the next form that will be displayed.
The code is not working as it should. The first form choices are radio buttons which are commercial and private. If the user chooses commercial it brings the next form and if the user chose private it brings a different form. My problem is that if the user chose private or commercial it brings the same form.
Views.py

from django.shortcuts import render
from datacollector.forms import  CustomerTypeForm, CustomerInfoForm1, CustomerInfoForm2, CustomerDocumentForm
from django.urls import reverse
from django.http import HttpResponse, HttpResponseRedirect



# Create your views here.

def step1formview(request):
    initial = {'customer_chioces': request.session.get('customer_chioces', None), }    
    form = CustomerTypeForm(request.POST or None, initial=initial)
    if request.method == 'POST':
        if form.is_valid():
            if form.customer_choices.choices == Commercial:
                return HttpResponseRedirect(reverse('datacollector:step2aformview'))
            else:
                return HttpResponseRedirect(reverse('datacollector:step2bformview'))
           
    return render(request, 'forms/CustomerTypeForm.html', {'form': form})     

template

{% extends 'base.html' %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>

    {% block head %}
    {% endblock %}
</head>
<body>

    {% block content %}

    {% if form.customer_choices.widget.choices == 'commercial' %}
    <form action="{% url 'datacollector:step2aformview' %}" method="post">
        {% csrf_token %}
        {{ form }}
        <input type="submit" value="Submit">
    </form>
    {% else %}

    <form action="{% url 'datacollector:step2bformview' %}" method="post">
        {% csrf_token %}
        {{ form }}
        <input type="submit" value="Submit">
    </form>

    {% endif %}

    {% endblock %}
    
</body>

</html>

forms.py

from .models import CustomerInfo, CustomerDocument 
from django.forms import ModelForm
from django import forms



CUSTOMER_CHOICES = [
    ('commercial', 'Commercial'),
    ('private', 'Private'),
]

class CustomerTypeForm(forms.Form):
    customer_chioces = forms.CharField(label="Customertype", 
            widget=forms.RadioSelect(choices=CUSTOMER_CHOICES))
    
   
#Commercial customer information
class CustomerInfoForm1(ModelForm):
    class Meta:
        model = CustomerInfo
        fields = "__all__"

#Private customer information
class CustomerInfoForm2(ModelForm):
    class Meta:
        model = CustomerInfo
        fields = ['name1', 'name2', 'name3', 'street', 'house', 'zip1', 'city']
        

class CustomerDocumentForm(forms.ModelForm):
    class Meta:
        model = CustomerDocument
        fields = ['document']

Please do not post images of code here. Copy/paste the code into the body of your message, between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted, which is critical with Python.

Thank you, sir. Please how can I solve this problem now?

It’s done. Can you look into the code?

You’re redirecting to the same view on both sides of this conditional.

It was a mistake I made while I was checking it. But if I changed the line it will still give me the same response.

What is the code for those two views?

If the user will choose a choice between private and commercial. If he chose commercial he will be redirected to the form with ‘step2bformview’ views. If he chooses the second option which is private, he will be redirected to another form with ‘step2bformview’ views.

This is the code for the two other views:

def step2aformview(request):
    initial_dict = {
        "name1" : request.session.get('name1', None),
        "name2" : request.session.get('name2', None),
        "name3":request.session.get('name3', None),
        "street":request.session.get('street', None),
        "house" : request.session.get('house', None),
        "zip1" : request.session.get('zip1', None),
        "city":request.session.get('city', None),
        "vat_ID":request.session.get('vat_ID', None),
        "tax_office_designation" :request.session.get('tax_office_designation', None),
        "tax_office_address":request.session.get('tax_office_address', None),
    }
    form = CustomerInfoForm1(request.POST or None, initial=initial_dict)
    if request.method == 'POST':
        if form.is_valid():
            return HttpResponseRedirect(reverse('datacollector:step3formview'))
    return render(request, 'forms/CustomerInfoForm1.html', {'form': form})



def step2bformview(request):
    initial_dict = {
        "name1" : request.session.get('name1', None),
        "name2" : request.session.get('name2', None),
        "name3":request.session.get('name3', None),
        "street":request.session.get('street', None),
        "house" : request.session.get('house', None),
        "zip1" : request.session.get('zip1', None),
        "city":request.session.get('city', None),
      }
    form = CustomerInfoForm2(request.POST or None, initial=initial_dict)
    if request.method == 'POST':
        if form.is_valid():
            return HttpResponseRedirect(reverse('datacollector:step3formview'))
    return render(request, 'forms/CustomerInfoForm2.html', {'form': form})

What does your urls.py file look like?

Note, there is one thing I am noticing. You’re relying a lot upon the session for holding data from these form submissions, but I’m not seeing any code where you’re saving any data into the session. Where are you doing that?

So what line of code will i use to save the data. I guess that is the problem

See the docs at https://docs.djangoproject.com/en/4.1/topics/http/sessions/.

You can easily do it with the form wizard of django and - formtools. A simple example can be something like django format class.
how to clean divan bed base