基于 this关于 formset_factory 的回答,我尝试对 modelformset_factory 做同样的事情:
from django.utils.functional import curry
from functools wraps
AccountMemberFormSetBase = modelformset_factory(AccountMember,
form=wraps(AccountMemberLimitedModelForm)(curry(AccountMemberLimitedModelForm, affiliate="test")),
extra=2)
这会引发以下错误:
function() argument 1 must be code, not str
Exception Location: ../django/forms/models.py in modelform_factory, line 528
知道这里出了什么问题吗?
最佳答案
今天我发现自己处于同样的情况。
请参阅我在 Django Passing Custom Form Parameters to Formset 中的评论有关详细信息和解决方法(我希望 StackOverflow 本身的链接是可以接受的)。
关于python - Django 将自定义表单参数传递给 modelformset_factory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24533283/