Wednesday, January 18, 2012

ImageField filename

How do I get the actual filename of the uploaded image?

The docs mention ...

FileField.upload_to
A local filesystem path that will be appended to your MEDIA_ROOT setting
to determine the value of the url attribute.

... and presumably the widget which uploads the image knows the filename
to tack onto the end of upload_to when the webserver gets the request to
store the image.

But how can I get access to that filename in the model so I can parse it
and give it a meaningful (to humans) name when being saved?

The docs go on to mention upload_to as a callable but I'm sticking to a
fixed directory in MEDIA_ROOT for these images.

Thanks for any hints

Mike

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate