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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:08:37+00:00 2026-05-12T08:08:37+00:00

im asking again :), i don’t know how make this. My English is not

  • 0

im asking again :), i don’t know how make this.

My English is not too good, but ill try to asking this:

how ill validate a form and go back to the preview url (the same view form) and show the validation errors?, im asking this because i have 2 form’s, the first form’s action is going to a second form (POST), but in this second form (view?) i need to validate the first form, if the first form is valid i want to show the second form else ill show the first form with errors.

i dont know if im clear , im sorry.

im thinking about this:

def secondForm(request):
    if request.method =='POST':
       form = FirstForm(request.POST)
       if form.is_valid():
          fields = request.POST.copy()
          # showing the second form?? with x differents fields, i have 2.
          if fields['xvalue']=='1': # this is from radio buttons
             form2 = xSecondForm()
          elif fields['xvalue']=='2':
             form2 = ySecondForm()
       else:
         # here go back with erros msgs????
         #return render_to_response('firstFormTemplate.html',{'form': form}, context_instance=RequestContext(request))
    else:
      #return something or go back ???

Thanks guys
PD: im happy, im coding Django + python 😀

  • 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-05-12T08:08:37+00:00Added an answer on May 12, 2026 at 8:08 am

    Yes, formwizard might be your answer, but you could probably do it with some logic in a view.

    Something like:

    def your_view(request):
        context = {}
        data = request.method == 'POST' and request.POST or None
        form = FirstForm(data=data)
        # If the first form is valid, build the second.
        if form.is_valid():
            if form.cleaned_data['xvalue'] == 1:
                form2 = xSecondForm(data=data)
            else:
                form2 = ySecondForm(data=data)
            context['form2'] = form2
        # If both forms are valid, everything is done.
        if form.is_valid() and form2.is_valid():
            # TODO: put save/processing logic here
            # Now redirect.
            return http.HttpResponseRedirect(...)
        # If we get here, either there hasn't been a post yet, the second form hasn't
        # been entered, or there was an error in either form.
        context['form'] = form
        return render_to_response(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel pretty stupid asking this, but as I don't know the answer, I'm
Sorry for asking this again but ppl seem to connect csrf only with form
I know what I asking might not make a lot of sense for C#
this is my first time asking something here, so don't be too harsh on
This is an accident and I don't think there's a solution. But I'm asking
Description This is not a real world example! Please don't suggest using decimal or
I'm not asking how to implement this, it's simple enough concept. What I'm having
EDIT AGAIN : I don't want to create another question, so asking here. I
I apologize in advance for asking this question, I know similar questions have already
Once again I'm asking this question, and still can't find any reasonable solution. I

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.