Re: Overriding save method in model

2009-05-06 Thread Thierry
I don't exactly want to save the full path of the image in the database, just the image extension. I am trying to convert the current implementation of a PHP web page to Django. Here's how the table looks like, I'll be more explicit with the img ext this time: idname img_ext

Re: Overriding save method in model

2009-05-06 Thread Daniel Roseman
On May 5, 10:15 pm, Thierry wrote: > How can I set picture to the image extension?  I don't think > "instance.picture = ext" works: > >  def pet_picture_upload(instance, filename): >      name, ext = os.path.splitext(filename) >      instance.picture = ext >      return

Re: Overriding save method in model

2009-05-05 Thread Thierry
How can I set picture to the image extension? I don't think "instance.picture = ext" works: def pet_picture_upload(instance, filename): name, ext = os.path.splitext(filename) instance.picture = ext return '/usr/django/images/%s%s' % (instance.pk, ext) On May 5, 3:48 pm, Daniel

Re: Overriding save method in model

2009-05-05 Thread Daniel Roseman
On May 5, 8:00 pm, Thierry wrote: > I have the following model: > > class Pet(models.Model): >     name = models.CharField(max_length=64) >     picture = models.ImageField(upload_to='/usr/django/images/') > >     def save(self, force_insert=False, force_update=False): >    

Overriding save method in model

2009-05-05 Thread Thierry
I have the following model: class Pet(models.Model): name = models.CharField(max_length=64) picture = models.ImageField(upload_to='/usr/django/images/') def save(self, force_insert=False, force_update=False): // override the picture values super(Pet,