Ah, I figured it out.

class ProductImage(models.Model):
  image = models.ImageField(upload_to='images', height_field='height',
width_field='width')

Example:
>>> p = ProductImage.objects.all()[0]
>>> p.image.height
250
>>> p.image.width
100



On Sep 12, 12:06 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Can someone explain how to use theheight_fieldand width_field for an
> ImageField as it would relate to this model:
>
> class ProductImage(models.Model):
>   image = models.ImageField(upload_to='images')
>
> The explanation in the documentation is:
> Name of a model field which will be auto-populated with the height of
> the image each time the model instance is saved.
>
> I don't think that's 100% clear.  At least to me its not.  I tried
> this:
>
> class ProductImage(models.Model):
>   height = models.IntegerField()
>   width = models.IntegerField()
>   image = models.ImageField(upload_to='images',height_field=height,
> width_field=width)
>
> Must I do anything else specific with my model or am I way off?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to