Django: Podczas zapisywania, jak możesz sprawdzić, czy pole się zmieniło?

W moim modelu mam:

class Alias(MyBaseModel):
    remote_image = models.URLField(max_length=500, null=True, help_text="A URL that is downloaded and cached for the image. Only
 used when the alias is made")
    image = models.ImageField(upload_to='alias', default='alias-default.png', help_text="An image representing the alias")


    def save(self, *args, **kw):
        if (not self.image or self.image.name == 'alias-default.png') and self.remote_image :
            try :
                data = utils.fetch(self.remote_image)
                image = StringIO.StringIO(data)
                image = Image.open(image)
                buf = StringIO.StringIO()
                image.save(buf, format='PNG')
                self.image.save(hashlib.md5(self.string_id).hexdigest() + ".png", ContentFile(buf.getvalue()))
            except IOError :
                pass

Co działa świetnie po raz pierwszyremote_image zmiany.

Jak mogę pobrać nowy obraz, gdy ktoś zmodyfikowałremote_image na aliasie? Po drugie, czy istnieje lepszy sposób buforowania zdalnego obrazu?

questionAnswers(23)

yourAnswerToTheQuestion