1、form按field自定义
官方文档上:https://docs.djangoproject.com/zh-hans/2.1/ref/forms/validation/写着可以用字段名
from django import forms class ContactForm(forms.Form): # Everything as before. ... def clean_recipients(self): data = self.cleaned_data['recipients'] if "fred@example.com" not in data: raise forms.ValidationError("You have forgotten about Fred!") # Always return a value to use as the new cleaned data, even if # this method didn't change it. return data