TAGS :Viewed: 27 - Published at: a few seconds ago
[ Django Passing Custom Form Parameters to modelformset_factory ]
based upon this answer regarding formset_factory, I tried to do the same thing for modelformset_factory:
from django.utils.functional import curry
from functools wraps
AccountMemberFormSetBase = modelformset_factory(AccountMember,
form=wraps(AccountMemberLimitedModelForm)(curry(AccountMemberLimitedModelForm, affiliate="test")),
extra=2)
This throws the following error:
function() argument 1 must be code, not str
Exception Location: ../django/forms/models.py in modelform_factory, line 528
Any idea whats wrong here?
Answer 1
I found myself in the same situation today.
See my comment in Django Passing Custom Form Parameters to Formset for details and a workaround (I hope a link to StackOverflow itself is acceptable).