Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#9545 closed (worksforme)

FileField: height_field and width_field are not working

Reported by: julian24 Owned by: nobody
Component: File uploads/storage Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With this model height_field and width_field aren't working:

class Wallpaper(models.Model):
        title = models.CharField(_('Title'), max_length=80)
        wallpaper = models.ImageField(_('Wallpaper'),
          upload_to = 'wallpapers/',
          height_field = 'wallpaper_height',
          width_field = 'wallpaper_width')
        wallpaper_height = models.IntegerField(_('Wallpaper height'), blank=True, null=True)
        wallpaper_width = models.IntegerField(_('Wallpaper width'), blank=True, null=True)
        
        def __unicode__(self):
                return unicode(self.title)

But if I add the following save method, it works fine:

        def save(self):
                if self.wallpaper.field.width_field:
                        setattr(self.wallpaper.instance, self.wallpaper.field.width_field, self.wallpaper.width)
                if self.wallpaper.field.height_field:
                        setattr(self.wallpaper.instance, self.wallpaper.field.height_field, self.wallpaper.height)
                super(Wallpaper, self).save()

Change History (5)

comment:1 by Karen Tracey, 16 years ago

What does "aren't working" mean? Is this possibly the same as #8208?

comment:2 by julian24, 16 years ago

It means that the fields are empty.

comment:3 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:4 by Alex Gaynor, 16 years ago

Resolution: worksforme
Status: newclosed

There are now several tests for this, I'm going to mark as worksforme, if you can show case where it doesn't work please reopen with a testcase.

comment:5 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top