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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:26:05+00:00 2026-06-14T20:26:05+00:00

I hope this is clear – I would think it’s a pretty standard thing

  • 0

I hope this is clear – I would think it’s a pretty standard thing to need to do.

I want to create a formset with a number of empty forms, but the number of blank forms needs to vary each time the formset is rendered. For example I can get 2 empty forms with:

MyFormSet = inlineformset_factory(ParentModel, MyModel, extra=2)
# and in the view...
f = MyFormSet() # has 2 empty forms.

But the problem is I don’t know initially how many empty forms I want. Suppose I wanted to render a number of forms in an inline model formset in reponse to a GET parameter. MyFormSet() will now always give me 2, no more no less.

I’d like something like this:

MyFormSet = inlineformset_factory(ParentModel, MyModel)
# In the view...
f = MyFormSet(extra=some_number())
# ... render f

But obviously that doesn’t work. Do I need to redefine MyFormSet using the formset_factory every time I want to render the formset with a different number of blank forms? Or am I missing something obvious?

  • 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-06-14T20:26:06+00:00Added an answer on June 14, 2026 at 8:26 pm

    You can just call inlineformset_factory with a dynamic extra parameter in your view, no problem. The django admin is even more dynamic than that ( subclassing on the fly and so on ).

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

Sidebar

Related Questions

I hope this is clear and thanks in advance, I would like to change
This is my first question on Stack Overflow, so I hope that I'm clear
This is my first question in this forum, so i hope to be clear:
Hope this is not a dupe. I would like to be able to do
I want ActiveRecord to lookup by a non-id column from a table. Hope this
Hope this is clear enough: class myParent(): def __init__( self ): self.parentNumber = 5
I need ideas to try to make this program more readable. I think that
Hope this question is not stupid since I am an amateur web designer. I
Hope this is the right place to be asking this, so my apologies if
Hope this isn't a waste of your time. I'm working on a project, and

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.