私はBaseInlineFormSetのサブクラスであるフォームを持っています。関連モデルのフィールドの1つとして、そのウィジェットを変更したいと思います。ここでは、フォームのための私のコードは次のとおりです。Django - BaseInlineFormSetのサブクラスでフィールドのウィジェットを変更します。
class MyForm(forms.models.BaseInlineFormSet):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.forms[0].error_css_class = 'error'
self.forms[0].required_css_class = 'required'
class Meta:
model = MyModel
# here I am trying.
# recommend is an IntegerField in MyModel, which -
# I like to make it render in the form as a Radio Select (yes, no)
widgets = {'recommend': {forms.RadioSelect}}
すべてのヘルプと入力が
開始するには、 'BaseInlineFormSet'はインナーを使用していません: –