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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:47:24+00:00 2026-06-15T08:47:24+00:00

I have a ModelForm class which can be used one or more times on

  • 0

I have a ModelForm class which can be used one or more times on a single page. E.g.:

class ProductForm(forms.ModelForm):

    class Meta:
        model = Product
        exclude = ('prod_seq_number')

now when I want to use the form more than once on a single page, e.g.:

prodforms = []
for i in (range(nrofproducts)):
    prodforms.append(ProductForm())

I can now pass the list prodforms to the template and the user can enter multiple products on the page. The variable nrofproducts is: 1, 2, 4, 8 or 16

This won’t work because I will get form elements with identical names. I need to be able to differentiate between the various form elements. So I need a way to modify the form attributes
for instance by appending the index ‘i’ from the loop in the view code the ‘name’ attribute of the form. Any help would be appreciated.

The reason for making a form layout like this is that a user can choose to see 1, 2, 4, 8 or 16 products on a single page and I want a entry form to resemble the layout which he will see when finished.

  • 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-15T08:47:25+00:00Added an answer on June 15, 2026 at 8:47 am

    You really don’t want to do this. Simpler way of doing it would be to use Django Formset

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

Sidebar

Related Questions

I have this: class OrderForm(ModelForm): class Meta: model = Order exclude = ('number',) def
I have following form: class EmailPreferences(forms.ModelForm): Base form used for fields that are always
I have a model service and a ModelForm named Service which I use to
I have a class and it's modelForm. class UserGoal(models.Model): user = models.ForeignKey(User) goal =
I have this model and modelform: class Comment(models.Model): text = models.CharField(max_length=100) def clean_text(self): print
I have a model which represents a work order. One of the fields is
I have a modelform which has one field that is a ForeignKey value to
I have a ModelForm where one of the field (named creator ) is a
have written this little class, which generates a UUID every time an object of
Have deployed numerous report parts which reference the same view however one of them

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.