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 95873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:43:35+00:00 2026-05-10T23:43:35+00:00

I want to implement a simple 2 part FormWizard. Form 1 will by dynamically

  • 0

I want to implement a simple 2 part FormWizard. Form 1 will by dynamically generated something like this:

class BuyAppleForm(forms.Form):    creditcard = forms.ChoiceField(widget = forms.RadioSelect)    type = forms.ChoiceField(widget = forms.RadioSelect)    def __init__(self,*args, **kwargs):         user = kwargs['user']         del kwargs['user']          super(BuyAppleForm, self).__init__(*args, **kwargs)          credit_cards = get_credit_cards(user)         self.fields['creditcard'].choices = [(card.id,str(card)) for card in credit_cards]          apple_types= get_types_packages()         self.fields['type'].choices = [(type.id,str(type)) for type in apple_types] 

This will dynamically create a form with lists of available choices.

My second form, I actually want no input. I just want to display a confirmation screen containing the credit card info, apple info, and money amounts (total, tax, shipping). Once user clicks OK, I want the apple purchase to commence.

I was able to implement the single form way by passing in the request.user object in the kwargs. However, with the FormWizard, I cannot figure this out.

Am I approaching the problem wrong and is the FormWizard not the proper way to do this? If it is, how can the Form __init__ method access the user object from the HTTP request?

  • 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. 2026-05-10T23:43:35+00:00Added an answer on May 10, 2026 at 11:43 pm

    I don’t know if answering one’s own question is an acceptable behaviour on StackOverflow, here is my solution to my own problem.

    First, ditch FormWizard.

    I have one form. Two views: buy_apples and buy_apples_confirm

    First view only handles GET. It prints out the unbound form, with an action to go to the URL of the second view.

    The second view checks for the presence of a POST parameter named ‘confirm’. If it is not present (as it is not when the view is loaded the first time) it:

    1. Adjusts the widget on all the fields to be HiddenInput
    2. Writes out template which gives an order summary. This template also sets a hidden field called ‘confirm’ to 1 (even though this field does not exist on the Form)

    When the user clicks to buy the apples, the form is submitted back and the buy_apples_confirm view is invoked one more time. This time, a POST parameter called ‘confirm’ is present, so we actually process the purchase transaction and the user gets his apples.

    I welcome any critiques on this method or better ways of handling the situation. I am new to Django and find that there are many different ways of approaching a problem. I want to learn from the best though.

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

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You would do it like so. Note that 'locationInView' will… May 11, 2026 at 11:44 am
  • added an answer Go to the eclipse download site and click on member… May 11, 2026 at 11:44 am
  • added an answer You could use an abstract (MustInherit) Class instead of an… May 11, 2026 at 11:44 am

Related Questions

I want to implement a simple 2 part FormWizard. Form 1 will by dynamically
I want to implement a simple debug log, which consists of a table into
I know it's simple to implement, but I want to reuse something that already
I want to implement a paperless filing system and was looking to use WIA
I want to implement a two-pass cache system: The first pass generates a PHP
I want to implement a docking library in wpf with behavior similar to Adobe
Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first
I'm writing a Java game and I want to implement a power meter for
I'm using qt 4.4.3 with c++. I want to implement a QDomDocumentFragment object, and
I want to implement in Java a class for handling graph data structures. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.