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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:15:24+00:00 2026-05-28T04:15:24+00:00

I am trying to pass an argument asins to each form in a modelformset,

  • 0

I am trying to pass an argument asins to each form in a modelformset, so i followed the solution described here https://stackoverflow.com/a/624013/389453, heres the code

VariationFormSet = modelformset_factory(Variation, form=VariationASINMatch, extra=0)
VariationFormSet.form = staticmethod(curry(VariationFormSet, asins=extra_asins))
formset = VariationFormSet(request.POST or None, request.FILES or None, queryset=variation_q)

heres the form :

class VariationASINMatch(forms.ModelForm):

    def __init__(self, asins, *args, **kwargs):
        instance = kwargs['instance']
        super(VariationASINMatch, self).__init__(*args, **kwargs)
        self.fields['asin'] = fields.ChoiceField(choices=asins[instance.upc])


    class Meta:
        model = Variation
        fields = ('child_sku', 'upc', 'asin', 'id_type')

unfortunately for some reason the curry is causing this errror:

Traceback:
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  197.             return view(request, *args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  28.             return bound_func(*args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  24.                 return func(self, *args2, **kwargs2)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view
  1079.                 response = self.response_action(request, queryset=cl.get_query_set())
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/contrib/admin/options.py" in response_action
  836.             response = func(self, request, queryset)
File "/home/paulo/Documents/Projects/tsn_env/tsn/../tsn/product/admin.py" in get_variation_asins
  130.             formset = VariationFormSet(request.POST or None, request.FILES or None, queryset=variation_q)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/models.py" in __init__
  415.         super(BaseModelFormSet, self).__init__(**defaults)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/formsets.py" in __init__
  47.         self._construct_forms()
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms
  108.             self.forms.append(self._construct_form(i))
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
  443.         return super(BaseModelFormSet, self)._construct_form(i, **kwargs)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_form
  127.         form = self.form(**defaults)
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/utils/functional.py" in _curried
  55.         return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File "/home/paulo/Documents/Projects/tsn_env/lib/python2.7/site-packages/django/forms/models.py" in __init__
  415.         super(BaseModelFormSet, self).__init__(**defaults)

Exception Type: TypeError at /admin/product/product/
Exception Value: __init__() got an unexpected keyword argument 'instance'

i have looked for solutions to this, but found none so far, i welcome any solutions/suggestions. Thanks

  • 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-28T04:15:24+00:00Added an answer on May 28, 2026 at 4:15 am

    So i finally solved this, the error is here :

    VariationFormSet = modelformset_factory(Variation, form=VariationASINMatch, extra=0)
    VariationFormSet.form = staticmethod(curry(VariationFormSet, asins=extra_asins))
    

    instead of giving curry the Form class VariationASINMatch, i gave it the formset class VariationFormSet

    so it should look like this

    VariationFormSet = modelformset_factory(Variation, form=VariationASINMatch, extra=0)
    VariationFormSet.form = staticmethod(curry(VariationASINMatch, asins=extra_asins))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to pass a string argument to a function, which will then be used
I'm trying to pass a string argument to a target function in a process.
I'm trying to pass a 'string' argument to a view with a url. The
I'm trying to pass UTF-8 text as an argument to a command line program
I am trying to start a new thread and pass an argument to one
I'm trying to pass a form field of type file to a CFFUNCTION. The
Wondering what I am doing wrong here. I am trying to pass an integer
Iam trying to pass dynamic argument values i.e username from request using spring ioc.But
In this jsFiddle am I trying to pass an argument to a function, but
I am trying to either pass an argument or set a variable for a

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.