Hello,

I'm trying to convert an image using PIL but I have lots of problems
with that. I have reduced my model to the simplest one, as I'm getting
a "file not foun error" on PIL



class Imatges( models.Model ):
   imatge = models.ImageField( upload_to='fotos' )

   def _before_save(self):
       print "Pre Save"
       filename = self.get_imatge_filename()
       print "Url : ", self.get_imatge_url()
       print "FileName : ", filename

   def _after_save(self):
       print "Post save"
       filename = self.get_imatge_filename()
       print "Url : ", self.get_imatge_url()
       print "FileName : ", filename

   def save( self ):
       self._before_save()
       super( Imatges, self ).save()
       self._after_save()

   class Admin:
       pass


When I use it on the admin framework, I can see how the save method is
called twice. Here is the log:

Pre Save
Url :
FileName :
Post save
Url :
FileName :
Pre Save
Url :  http://localhost/~aaloy/django/fotos/IMG_0022.JPG
FileName :  /home/aaloy/public_html/django/fotos/IMG_0022.JPG
Post save
Url :  http://localhost/~aaloy/django/fotos/IMG_0022.JPG
FileName :  /home/aaloy/public_html/django/fotos/IMG_0022.JPG

The first time the imatge field has no values, but It has them the
second one. Perhaps this is not the best way to do such things, but
calling save twice sounds like a bug.

Any ideas?

Best regards,


-- 

Antoni Aloy López
Binissalem - Mallorca
Soci de Bulma

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to