Django and ImageField Question

Posted by Hellnar on Stack Overflow See other posts from Stack Overflow or by Hellnar
Published on 2010-03-18T17:52:02Z Indexed on 2010/03/18 18:31 UTC
Read the original article Hit count: 625

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-model