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

  • SEARCH
  • Home
  • 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 9230309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:47:39+00:00 2026-06-18T05:47:39+00:00

This question is highly related to one that was previously asked and answered here:

  • 0

This question is highly related to one that was previously asked and answered here: How wrap a FormWizard in a View?

Can someone post exact details of how they have successfully wrapped a Django Form Wizard into a view so that the login_required decorator can be used? There are numerous discussions of this topic on the internet but they all seem to be incomplete because they don’t actually show how they have defined their Form Wizard class.

When I run point my browser to the view, I get the following exception:

__init__() takes exactly 1 non-keyword argument (2 given) in views.py line #108

What arguments do I pass when I instantiate my Form Wizard object such that it doesn’t give me this error?
If you have some sample code that works, please post it.

Here is whats in my urls.py file:

url(r'^createObject/$', views.createObjectView, name='createObject'),

Here is whats in my views.py file:

CREATE_OBJECT_FORMS = [
    ("createMyForm0", createObjectForm0),
    ("createMyForm1", createObjectForm1),
    ("createMyForm2", createObjectForm2),
    ("createMyForm3", createObjectForm3),
]

CREATE_OBJECT_TEMPLATES = {
    "createMyForm0": "myApp/form0.html",
    "createMyForm1": "myApp/form1.html",
    "createMyForm2": "myApp/form2.html",
    "createMyForm3": "myApp/form3.html",
}




@login_required
def createObjectView(request):
    # Set up the dictionary of initial data for the form
    # In this case, we are pre-filling some data from the first form only
    initial = {0: {}}

    # Create the form wizard
    form = createObjectWizard(
        [
            createObjectForm0,
            createObjectForm1,
            createObjectForm2,
            createObjectForm3,
        ], 
        initial=initial      # This is Line #108
    )

    # Call the form wizard passing through the context and the request
    return form(context=RequestContext(request), request=request)    




class createObjectWizard(SessionWizardView):
    def get_template_names(self):
        return [CREATE_OBJECT_TEMPLATES[self.steps.current]]

    def done(self, form_list, **kwargs):
        doSomethingFunction(form_list)
        return HttpResponseRedirect('/objectCreated/')
  • 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-18T05:47:40+00:00Added an answer on June 18, 2026 at 5:47 am

    The as_view function converts a class based view into a callable view:

    myapp/views.py

    from django import forms
    from django.contrib.auth.decorators import login_required
    from django.contrib.formtools.wizard.views import SessionWizardView
    from django.template.response import TemplateResponse
    
    class Form1(forms.Form):
        a = forms.CharField()
    
    class Form2(forms.Form):
        b = forms.CharField()
    
    FORMS = [("step1", Form1),
             ("step2", Form2)]
    
    TEMPLATES = {"step1": "wizard_step.html",
                 "step2": "wizard_step.html"}
    
    class MyWizard(SessionWizardView):
    
        def get_template_names(self):
            return [TEMPLATES[self.steps.current]]
    
        def done(self, form_list):
            # get data from forms
            a = self.get_cleaned_data_for_step('step1')['a']
            b = self.get_cleaned_data_for_step('step2')['b']
            # access the request as self.request
            request = self.request
            # (...)
            # return response
            return TemplateResponse(request, 'wizard_success.html', {
                'a': a,
                'b': a
            })
    
    wizard_view = MyWizard.as_view(FORMS)
    
    @require_login
    def wrapped_wizard_view(request):
        return wizard_view(request)
    

    myapp/templates/wizard_step.html

    {% extends "base.html" %}
    {% load i18n %}
    
    {% block content %}
    
    <form method="post">
    {% include "formtools/wizard/wizard_form.html" %}
    </form>
    
    {% endblock %}
    

    myapp/urls.py

    from django.conf.urls import patterns, url
    
    urlpatterns = patterns('myapp.views',
        url(r'^wizard/$', 'wrapped_wizard_view'),
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's highly probable this question has been asked, but I can't find the answer.
This is my first question asked here at stackoverflow, so bear with me please
This is a NEW question and it is highly related to this topic: How
This is not exactly a programming question, but it's highly related. We are writing
In this highly-praised answer to the question How do you use bcrypt for hashing
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
This question is similar in concept to this one , except I see I
This question is related to another question I wrote: Trouble using DOTNET from PHP.
This question is based on a previous , but that's just FYI. I've managed

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.