This below are the classes in my models.py.
class Category(models.Model):
TRAVEL = 'TR'
WEDDING = 'WE'
PORTRAITURE = 'PR'
CATEGORIES = (
('TRAVEL', 'travel'),
('WEDDING', 'wedding'),
('PORTRAITURE', 'portraiture'),
)
category = models.CharField(
max_length=32,
choices=CATEGORIES,
default='PORTRAITURE',
)
class Image(models.Model):
image = models.ImageField((""), upload_to='images/', height_field=None, width_field=None, max_length=None, blank=True)
image_name = models.CharField(max_length=60)
image_description = models.TextField()
location = models.ForeignKey(Location, null=True)
category = models.ForeignKey(Category, default='PORTRAITURE')
pub_date = models.DateTimeField(default=datetime.now, blank=True)
tags = models.ManyToManyField(tags)
Ignore the part below.
Has two optional arguments for validation, max_length and allow_empty_file. If provided, these ensure that the file name is at most the given length, and that validation will succeed even if the file content is empty.
To learn more about the UploadedFile object, see the file uploads documentation.
When you use a FileField in a form, you must also remember to bind the file data to the form.
The max_length error refers to the length of the filename. In the error message for that key, %(max)d will be replaced with the maximum filename length and %(length)d will be replaced with the current filename length