models.py
class OrderImage(TimeStampedModel):
img = models.ImageField()
name = models.CharField(max_length=40)
forms.py
class OrderImageForm(forms.ModelForm):
class Meta:
model = OrderImage
fields = ['img', 'name',]
def clean_name(self):
print("name")
def clean_img(self):
print("img")
我用clean_img
from IPython import embed; embed();
我测试了一下,
def test_a(self):
form = OrderImageForm({
'img':'b',
'name':'a'
})
form.is_valid()
当我测试时,它只打印name
....
为什么会这样?