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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:56:52+00:00 2026-05-20T22:56:52+00:00

I hope this question has not been asked yet, but I want to know

  • 0

I hope this question has not been asked yet, but I want to know if it is possible to have a normal class-based form for an object and to have an inline formset inside it to edit its related objects.

For example, I have a Contact model

class Contact(models.Model):
    ...

And a Communication model

class Communication(models.Model):
   contact = models.ForeignKey(Contact)

and I want to have a form for Contact with a inline formset nested in it for managing communications related to it.

Is it possible to do so with existing components or do I have a hopeless dream?

EDIT : I know that the admin panel does it, but how do I make work in a view?

  • 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-20T22:56:52+00:00Added an answer on May 20, 2026 at 10:56 pm

    Of course it’s possible – how do you think the admin does it?

    Take a look at the inline formsets documentation.

    Edited after comment Of course, you need to instantiate and render both the parent form and the nested formset. Something like:

    def edit_contact(request, contact_pk=None):
        if contact_pk:
            my_contact = Contact.objects.get(pk=contact_pk)
        else:
            my_contact = Contact()
        CommunicationFormSet = inlineformset_factory(Contact, Communication)
        if request.POST:
            contact_form = ContactForm(request.POST, instance=my_contact)
            communication_set = CommunicationFormSet(request.POST,
                                                     instance=my_contact)
            if contact_form.is_valid() and communication_set.is_valid():
                contact_form.save()
                communication_set.save()
        else:
            contact_form = ContactForm(instance=my_contact)
            communication_set = CommunicationFormSet(instance=my_contact)
     
        return render_to_response('my_template.html', 
                                  {'form': contact_form, 'formset':communication_set})
    

    and the template can be as simple as:

    <form action="" method="POST">
      {{ form.as_p }}
      {{ formset }}
    </form>
    

    although you’ll probably want to be a bit more detailed in how you render it.

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

Sidebar

Related Questions

I hope that this question has not been asked elsewhere, but I'm having difficulty
I hope this question has not been asked before. I have a csv file
This question has been asked before somewhat, but I hope mine differs. My situation
I know this question has been asked here before, but I don't think those
I'm not sure if this question has been asked before, but I can't seem
I know this question has already been asked, but my question is more general
I know that variations on this question have been asked, but I've tried all
Now I know this basic question has been asked before, but I must be
I hope this question has not been asked, I tried to search for similar
I know this question has been asked a million of times here at stackoverflow,

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.