#13784: pre_save is dispatched before executing upload_to attributes on 
FileFields
when using ModelForm
--------------------------------+-------------------------------------------
 Reporter:  peterbe             |       Owner:  nobody    
   Status:  new                 |   Milestone:            
Component:  Forms               |     Version:  1.2       
 Keywords:  ModelForm pre_save  |       Stage:  Unreviewed
Has_patch:  0                   |  
--------------------------------+-------------------------------------------
 Suppose you have this code:

 {{{
 def callable_upload_to(instance, filename):
     full_path = os.path.join(this_year(), filename)
     print "PLACING", full_path
     return full_path

 class Foo(models.Model):
     file = models.FileField(upload_to=callable_upload_to)
     size = models.IntegerField(null=True)

 def update_foo(sender, instance, **kwargs):
     print "UPDATING", str(instance.file)

 pre_save.connect(update_foo, sender=Foo)
 }}}

 Suppose you create one of these instances with a '''!ModelForm''' you'll
 get this output on stdout:
 {{{
 UPDATING sample.file
 PLACING 2010/sample.file
 }}}

 That means that you can't rely on the file path as dictated by the
 upload_to callable in your pre_save signal. Especially important is that
 within your {{{pre_save}}} method you can't even get to the file since it
 doesn't exist.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13784>
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-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to