Django and ImageField Question
- by Hellnar
Hello I have a such model:
Foo (models.Model):
slug = models.SlugField(unique=True)
image = models.ImageField(upload_to='uploads/')
I want to do two things with this:
First of all, I want my image to be forced to resize to a specific width and height after the upload.
I have tried this reading the documentation but seems to getting error:
image = models.ImageField(upload_to='uploads/', height_field=258, width_field=425)
Secondly, when adding an item via admin panel, I want my image's file name to be renamed as same as slug, if any issue arises (like if such named image already exists, add "_" to the end as it used to do.
IE: My slug is i-love-you-guys , uploaded image such have i-love-you-guys.png at the end.