Re: pre-save and check for existing value of image
you self.instance.fieldname use this ur from . On Tue, Nov 10, 2009 at 12:58 PM, Ramdas Swrote: > Hi, > > I have this app which has an ImageField, where the image needs to be > cropped, resized, and a few effects (all from PIL) are applied on it, the > model looks something like this > > class MidPanel(models.Model): > >. >image = models.ImageField(upload_to="images"): > >def save(self): > > if self.image: >dosomething(self.image) > > > Everything is fine, expect that every time someone makes a change to a > field in the model, the images gets manipulated. The image manipulation is > supposed to happen only once. > > What I want is somehow to apply the cmanipulation on self.image only if > the image is changed, or its been created... Is pre_seave the right way, if > so how do you actually use it where it need to compare previosly stored data > and the newone and then only execute. > > Ramdas > > > > -- > Ramdas S > +91 9342 583 065 > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
pre-save and check for existing value of image
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="images"): def save(self): if self.image: dosomething(self.image) Everything is fine, expect that every time someone makes a change to a field in the model, the images gets manipulated. The image manipulation is supposed to happen only once. What I want is somehow to apply the cmanipulation on self.image only if the image is changed, or its been created... Is pre_seave the right way, if so how do you actually use it where it need to compare previosly stored data and the newone and then only execute. Ramdas -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: pre-save and check for existing value of image
You can check whether there is instance or not by self.instance .This will tell u that whether it is change (page)or a new object is added.And if it new object then only call ur custom functions.U can also use changeForm function On Tue, Nov 10, 2009 at 12:39 PM, Ramdas Swrote: > Hi, > > I have this app which has an ImageField, where the image needs to be > cropped, resized, and a few effects (all from PIL) are applied on it, the > model looks something like this > > class MidPanel(models.Model): > >. >image = models.ImageField(upload_to="imgs") > > def save(self): >if self.image: > dosomething(image) > doanother2(self.image) > > > All this is fine. Expect that every time the model is saved, it executes > the manipulation on the image. What I require is an idea where the image > manipulation happens only if the image field is changed, and not unless. How > do I achieve that. > > Someone suggested me to use pre_vae signal, but I am not able to figure an > effcient way.. > > Can someone help > > -- > Ramdas S > +91 9342 583 065 > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
pre-save and check for existing value of image
Hi, I have this app which has an ImageField, where the image needs to be cropped, resized, and a few effects (all from PIL) are applied on it, the model looks something like this class MidPanel(models.Model): . image = models.ImageField(upload_to="imgs") def save(self): if self.image: dosomething(image) doanother2(self.image) All this is fine. Expect that every time the model is saved, it executes the manipulation on the image. What I require is an idea where the image manipulation happens only if the image field is changed, and not unless. How do I achieve that. Someone suggested me to use pre_vae signal, but I am not able to figure an effcient way.. Can someone help -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---