You can define a function that returns the path to upload the image, in
this function you receive as argument the object being saved (instance) and
the name of the file (filename). You can return whatever you want as a path
(that include the filename)
def upload_path(instance, filename):
return 'category/' + str(instance.name) + '/image/' + filename
class Category(models.Model):
name = models.CharField(_('name'), max_length=200, unique=True)
image = models.ImageField(_('image'), upload_to=upload_path, blank=True)
BR
Damián
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.