📜  设置表单字段已禁用 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:59.837000             🧑  作者: Mango

代码示例1
class PatientForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
       super(PatientForm, self).__init__(*args, **kwargs)
       self.fields['field'].widget.attrs['readonly'] = True

    class Meta:
        model = Patient