|

楼主 |
发表于 2023-6-14 17:36:15
|
显示全部楼层
本帖最后由 mingmei123 于 2023-6-14 17:37 编辑
from django import forms
class UserModelForm(forms.ModelForm):
name = forms.CharField(min_length=3, label="用户名")
class Meta:
model = models.UserInfo
fields = ["name", "password", "age", "account", "create_time", "gender", "depart"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for name, field in self.fields.items():
if name == "password":
continue
field.widget.attrs = {"class": "form-control", "placeholder": field.label}
|
|