#6714: let update_to accept a callable
-------------------------------------------------+--------------------------
Reporter: Griffith Rees <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component: Core framework
Version: SVN | Keywords: FileField
Models
Stage: Unreviewed | Has_patch: 0
-------------------------------------------------+--------------------------
It would be nice if the upload_to parameter on FileFields accepted a
callable as an argument. It could be called with the model instance as its
only variable the first time the instance needed to be saved to disk
(afterwards, it should rely on the database entry for the path).
Currently, it only accepts a formatting string, which means you cannot,
for example, upload files to directories based on their filesize or other
data (such as other attributes of the model instance).
{{{
class IssuePrintEdition(model.Model):
issue = ForeignKey(Issue) # The issue this print edition is related to
section = ForeignKey(Section)
file = FileField(upload_to=upload_path)
def upload_path(instance):
return "issues/%s/%s" % (instance.issue.title, instance.section)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/6714>
Django Code <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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---