I wrote the model like this:
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
And the form:
class BookInfoForm(forms.ModelForm):
class Meta:
model = Book
But whatever file I choose to upload, I just can’t get through the form validation, which always implies “this field is required”. Why?
From docs
Did you remember to set the form attribute enctype=”multipart/form-data”