Sunday, December 4, 2016

Re: ImageField always calling update_dimensions_fields

What I see is that when I load my page, it calls update_dimension_fields for every image. The model is simple.


class Photo(models.Model):
width = models.PositiveIntegerField(blank=True, null=True, editable=False, default="0")
height = models.PositiveIntegerField(blank=True, null=True, editable=False, default="0")
image = ImageField(upload_to=upload_to, width_field='width', height_field='height')
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="uploaded_photos")
title = models.CharField(max_length=255)
slug = extension_fields.AutoSlugField(populate_from='title', blank=True)
caption = models.CharField(max_length=255, blank=True)
date_added = models.DateTimeField(default=timezone.now)

class PhotoCollection(models.Model):
name = models.CharField('name', max_length=250)
slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
description = models.TextField(blank=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="uploaded_collections")
date_added = models.DateTimeField(default=timezone.now)
photos = models.ManyToManyField('photos.Photo', related_name='collections', blank=True)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/58bb16f7-c162-49da-8226-e388bce588ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment