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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:39:39+00:00 2026-05-25T21:39:39+00:00

I don’t have an example because I’m not working on anything relevant right now,

  • 0

I don’t have an example because I’m not working on anything relevant right now, but am still curious, after reading the docs about formsets:

What is a best practice for having a single view with multiple different model forms that post at the same time (rather 1 combined form, since you can’t post multiple forms at the same time, but for lack of a better explanation…), some being single model forms, and others being 1-or-more formsets (e.g. Person, his 1 Address, and his 1 or more Pet objects), like Django does with TabularInline. Inlines have been in Django for some times, so my suspicion is that there are better practices than what I may find by simply copy/pasting what’s in admin/options.py, no?

Thanks in advance

  • 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-25T21:39:39+00:00Added an answer on May 25, 2026 at 9:39 pm

    You should:

    • Make sure you’re using transactions (so, make sure they’re turned on, and that you’re using something other than MySQL with MyISAM tables). This is true all the time, really, but it’s even more true now. 🙂

    • Use multiple forms.Form/forms.ModelForm objects, which are grouped together in a single HTML <form> element, such as…

    Python:

    from django import forms
    
    class FormA(forms.ModelForm):
        [...]
    
    class FormB(forms.ModelForm):
        [...]
    

    HTML:

    <form method="post" action="/path/to/view/">
        {% csrf_token %}
    
        {{ form_a }}
        {{ form_b }}
    
        <input type="submit" value="Submit Form" />
    </form>
    

    Then, when you’re processing your forms, simply process them both and make sure that you’re requiring both to be valid to actually complete the view in a success case.

    from django.db import transaction
    from django.http import HttpResponseRedirect
    from django.template.response import TemplateResponse
    from myapp.forms import FormA, FormB
    
    @transaction.commit_on_success
    def present_forms_to_user(request):
        if request.method == 'POST':
            form_a = FormA(request.POST)
            form_b = FormB(request.POST)
    
            if form_a.is_valid() and form_b.is_valid():
                # processing code
    
                return HttpResponseRedirect('/path/to/thank/you/page/')
        else:
            form_a = FormA()
            form_b = FormB()
    
        return TemplateResponse(request, 'templates/eggs.html', {
            'form_a': form_a,
            'form_b': form_b,
        })
    

    As a disclaimer, remember that this is a basic example stub, and not meant to be copied blindly. Your ultimate use case for this may be slightly different, and that’s fine.

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

Sidebar

Related Questions

Don't know why, but sometimes LocationManager is still working also after closing application. I
Don't need to do this right now but thinking about the future... What would
I don't know if this question is trivial or not. But after a couple
Don't know if I worded the question right, but basically what I want to
Don't know if this is the right place to ask this, but I will
Don't ask why but I have the requirement to draw a border around certain
DON'T ASK WHY but... I have a regex that needs to be case insensitive
Don't ask me why but i can't use this method because I need to
Don't know why but I can't find a solution to this. I have 3
Don't you hate it when you have class Foobar { public: Something& getSomething(int index)

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.