0

我希望我的网站用户在视图中快速调整模型对象的一个​​属性(使用 htmx)

(为了避免仅使用其他字段属性创建大量 ModelForms)这就是为什么我想创建一个 ModelForm ,我可以在视图函数中定义表单实例化时显示的表单字段,所需的字段将作为“字段列表”传递参数到视图函数中,有点像这样:

class ModelForm(ModelForm):
   class Meta:
        model = Model
        fields = --> how to put the at the ModelForm-instantiation (with a request passed) "fieldlist" parameter here?

    def __init__(self, *args, **kwargs):
        fieldlist = kwargs.pop('fieldlist')
        super(ModelForm, self).__init__(*args, **kwargs)

任何提示?

4

0 回答 0