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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:59:41+00:00 2026-05-30T07:59:41+00:00

I have two forms: one that takes user information (name, birthdate, etc): formA. And

  • 0

I have two forms: one that takes user information (name, birthdate, etc): formA. And another one that contains a textfield the user can input text into: formB.

formB’s model has the actual textfield, and a “name” that links it to the user this text belongs to. This field is called text_name. text_name is a foreign key linked to the Name model (that’s linked to formA).

In my view’s template, I am only allowing the user to see the textbox they can input information into from formB, and they can also see all the fields in formA.
This means the text_name dropdown box is not displayed.

formA is currently being prepopulated with data from a different session.

This is my view:

def name(request):

    ses = request.session.get('ses',  None)

    formA = Name_Form(request.POST, instance = ses)
    formB = Text_Form(request.POST or None)
    formB.text_name = ses

    if request.method == 'POST':
            formB.text_name = ses
            if formA.is_valid() and formB.is_valid():
                    formB.note_job = ses
                    a = formA.save()
                    a.save()
                    b = formB.save()
                    b.save()

formB is not valid because text_name is not being populated. I tried populating using this line:

formB.text_name = ses

but that did not work.

How do I automatically populate text_name with the information inputted already without actually displaying text_name in my template and therefore forcing the user to actually choose the appropriate text_name manually.

  • 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-30T07:59:42+00:00Added an answer on May 30, 2026 at 7:59 am

    If you want to do extra processing on a model instance of a modelform before saving, there are at least two simple options:

    1. Access the modelform model instance before saving through form.instance: formB.instance.text_name = ses; formB.save()

    2. Save manually with commit=False: objB = formB.save(commit=False); objB.text_name = ses; objB.save(), in that case make sure that Text_Form has ‘text_name’ in it’s excluded field list.

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

Sidebar

Related Questions

I (currently) have two forms, one that needs to call the other. In other
I have encountered a problem in my application. I have two forms, one that
I have two forms, one with a radio button that users must select to
I have a form that has two buttons on it, one yes, one no,
I have two forms on one page and want to have the input boxes
I have two forms on a page (one is being grabbed by AJAX). I
I have two completely different forms in one template. How to process them in
How can two forms share the same inputs? I have two forms, one for
I have created two forms in my Windows Application. One Form acts as a
I'm using the jQuery Validation JS I have two contact forms, the main one

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.