Python Django模型表单集-修改表单标签和默认值

Python Django模型表单集-修改表单标签和默认值,python,django,django-forms,Python,Django,Django Forms,我正在构建这样一个模板集: InterestFormSet = modelformset_factory(Interest, \ formset=BaseInterestFormSet, exclude=('userid',), extra=2) 我想为这个表单的元素设置默认标签和值 我知道,在简单的表单中,我可以使用字段dict来更改表单特定字段的这些内容,但是如何使用表单集来实现这一点呢 我尝试扩展表单集(如您所见),以查看是否可以从\uuu init\uuu中访问self.fi

我正在构建这样一个模板集:

InterestFormSet = modelformset_factory(Interest, \
    formset=BaseInterestFormSet, exclude=('userid',), extra=2) 
我想为这个表单的元素设置默认标签和值

我知道,在简单的表单中,我可以使用
字段
dict来更改表单特定字段的这些内容,但是如何使用表单集来实现这一点呢


我尝试扩展表单集(如您所见),以查看是否可以从
\uuu init\uuu
中访问
self.fields
,但没有成功。

表单集没有字段,它们只有具有字段的表单。因此,您必须直接处理这些表单。

表单集没有字段,它们只有具有字段的表单。因此,您必须直接处理这些表单。

类似的内容应该可以满足您的需要:

class InterestForm(ModelForm):
    pub_date = DateField(label='Publication date')

    class Meta:
        model = Interest
        exclude = ('userid',)


InterestFormSet = modelformset_factory(Interest, form=InterestForm, extra=2)

像这样的东西可以满足您的需求:

class InterestForm(ModelForm):
    pub_date = DateField(label='Publication date')

    class Meta:
        model = Interest
        exclude = ('userid',)


InterestFormSet = modelformset_factory(Interest, form=InterestForm, extra=2)

是否有可能获取构成表单集的表单?是否有可能获取构成表单集的表单?