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
--
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 '/usr/django/images/%s%s'
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 R
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):
> // override the pi
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, self).save(force_
5 matches
Mail list logo