from app01 import models from django.core.validators import RegexValidator from django.core.exceptions import ValidationError from django import forms from app01.utils.bootstrap import BootStrapModelForm class UserModelForm(BootStrapModelForm): name = forms.CharField( min_length=2, label="用户名", widget=forms.TextInput(attrs={"class": "form-control"}) ) class Meta: model = models.UserInfo fields = ["name", "password", "age", 'account', 'create_time', "gender"] class MovieModelForm(BootStrapModelForm): class Meta: model = models.Movie exclude = ['id'] # 验证:方式2