On Mon, 2007-10-22 at 04:55 -0700, [EMAIL PROTECTED] wrote: > Hi, > > Playing on the latest SVN with newforms and FileFields, I was > wondering if there is a built-in way to retrieve the base filename of > a FileField. > Currently in my templates, {{ my_model.my_filefield }} displays the > uploaded filename appended to the value of 'upload_to', which I do not > find very attractive. Say a user uploads file 'readme.txt', I would > prefer to display 'render.txt', not 'uploaded_files/readme.txt'.
Unless you have some very special requirements, you don't want to display the filesystem path at all. You should be looking to display the URL associated with the file, which may or may not look like the file path. It sounds like you are looking for get_FOO_url(), which is documented in db-api.txt and available automatically for all FileField and subclasses. Even if you do want to display the file system path, I would recommend making your model, in that case, return that path as the URL (since it's how it is used in a template -- again, unless you are doing something really unusual, in which case you're going to have to dive under the covers anyway and it's definitely not an argument for a new helper method). Regards, Malcolm -- I just got lost in thought. It was unfamiliar territory. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---