1👍
✅
You need a custom upload handler.
def image_upload_handler(instance, filename):
return 'RANKS/{genre}/{filename}'.format(
genre=instance.genre,
filename=filename
)
class RankStructure(models.Model):
image = models.ImageField(upload_to=image_upload_handler, blank=True)
Also I recommend using this for image fields: https://github.com/edoburu/django-any-imagefield
Source:stackexchange.com