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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:21:26+00:00 2026-06-10T09:21:26+00:00

as per this SO question Django Passing Custom Form Parameters to Formset im tryin

  • 0

as per this SO question Django Passing Custom Form Parameters to Formset im tryin to use curry to pass a dictionary of initial values to my formset.

its not working, it gives me a formset of empty values, which isn’t what its supposed to do.

can anyone see if im implementing this wrong?

data = {'supplier': input_data['supplier'],}

InstanceFormSet = formset_factory(BulkAddInstanceForm, extra=int(input_data['copies']))
InstanceFormSet.form = staticmethod(curry(BulkAddInstanceForm, data))

EDIT: as requested

class BulkAddInstanceForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(BulkAddInstanceForm, self).__init__(*args, **kwargs)

        self.fields['supplier'] = forms.ModelChoiceField(
            queryset=Supplier.objects.all(),
            label='Supplier',
            empty_label='Select a Supplier...',
            required=True,
        )
        self.fields['syllabus'] = forms.ModelChoiceField(
            queryset=Syllabus.objects.all(),
            label='Syllabus',
            empty_label='Select a Syllabus...',
            widget=FilterWidget(
                queryset=Syllabus.objects.all(),
                parent_queryset=Supplier.objects.all(),
                control_name='supplier',
                parent_attr='supplier',
            ),
            required=False,
        )
        self.fields['venue'] = forms.ModelChoiceField(
            queryset=Venue.objects.all(),
            label='Venue',
            empty_label='Select a Venue...',
            widget=FilterWidget(
                queryset=Venue.objects.all(),
                parent_queryset=Supplier.objects.all(),
                control_name='supplier',
                parent_attr='supplier',
            ),
            required=False,
        )
    start_date = NiceDateField(required=False, label='Start Date')
    residential = forms.BooleanField(label='Res?', required=False)
    special_offers = forms.BooleanField(label='S/O?', required=False)
    manual_price = forms.IntegerField(required=False)
    manual_cost = forms.IntegerField(required=False)

edit2: FAO Brandon

I have looked at the docco and it suggests to do a different thing.

formset = formset_factory(BulkAddInstanceForm, extra=int(input_data['copies']))
formset = InstanceFormSet(initial=[data, ])

which creates a formset with ‘copies’ amount of forms, plus another one with the data in.
if i do this

formset = InstanceFormSet(initial=[data, data])

then i get two extra forms with the data in.
so my idea is i need an iterator to add ‘copies’ number of dictionaries and zero the initial number of forms in the formset.

not that i know how to cod that yet!!

  • 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-10T09:21:28+00:00Added an answer on June 10, 2026 at 9:21 am

    managed to do it with the following code:

    InstanceFormSet = formset_factory(BulkAddInstanceForm, extra=0)
    # build the list for populating the forms
        n, datalist = 0, []
        while n < int(input_data['copies']):
            datalist.append(data)
            print datalist
            n +=1
    
        formset = InstanceFormSet(initial=datalist)
    

    so i create the formset, then i create a list of the data dictionaries, then populate the formset with the inital data as a list.

    seems to be working so far, though i’ve got to work out how to collect and submit the info yet .

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

Sidebar

Related Questions

Per this question: Setting up rake-pipeline for use with handlebars alongside Google App Engine
Per this question (see comments near the bottom), I was wondering if anyone knows
I am having the same issues as per this question: WCF not deserializing JSON
I've started to become a Good Citizen, as per this question here: Domain compatibility:
As per the title I have three parts to this question... Is db4o object
This is not a programming question per se, although the ultimate goal is to
This is not a question of premature optimization per se. On the garbage collector
I had the following code as per this question&answer How do I get the
I am trying to make a WebForms project and ASP.NET MVC per this question
I'm trying to learn Crystal Reports (VS 2005, VB) and per this question I

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.