我写了这样的模型:
class Book(models.Model):
title = models.CharField(max_length = 200)
author = models.CharField(max_length = 50)
image = models.ImageField(upload_to = 'book/%Y/%m/%d')
def __unicode__(self):
return self.title
def get_absolute_url(self):
return '/book/%s' % self.title
形式:
class BookInfoForm(forms.ModelForm):
class Meta:
model = Book
但是无论我选择上传什么文件,我都无法通过表单验证,这总是意味着“此字段是必需的”。为什么呢?