#9545: FileField: height_field and width_field are not working
----------------------------------+-----------------------------------------
 Reporter:  julian24              |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  File uploads/storage  |     Version:  1.0       
 Keywords:                        |       Stage:  Unreviewed
Has_patch:  0                     |  
----------------------------------+-----------------------------------------
 With this model `height_field` and `width_field` aren't working:

 {{{
 #!python
 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:

 {{{
 #!python
         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()
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9545>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to