views.py
from django import forms from django.forms import widgets from django.forms import fields class FM(forms.Form): # Because fields such as charField can only be verified, the default input box is used. If you want to use other html, you need to use the widgets plugin to add styles. [Why, don't know]) user = fields.CharField(error_messages={'required':'Username cannot be empty'} ,widget=widgets.Textarea(attrs={'class':'c1'}) # attr can customize the style c1 ) # custom error message pwd = fields.CharField(max_length=12,min_length=6, error_messages={'required':"password cannot be empty","max_length":"password length is less than 12","min_length":"password length is greater than 6"}, widget=widgets.PasswordInput(attrs={'class':'c2'}) ) email = fields.EmailField(error_messages={'required':'The email address cannot be empty','invalid':"The email format is incorrect"})
process:
So if you write obj.user in fm.html, the input box will be generated by default. If you need to change it, you need to use the widgets plugin