Opened 16 years ago

Last modified 13 years ago

#7415 closed

FileFields have wrong url in admin under Windows, when using upload_to path — at Version 3

Reported by: edgars.jekabsons@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: windows filefield fs-rf-fixed
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

Right now (revision 7612) AdminFileWidget is implemented this way:

if value:
    output.append('%s <a target="_blank" href="%s%s">%s</a> <br />%s ' % \
                (_('Currently:'), settings.MEDIA_URL, value, value, _('Change:')))

The value in database contains \ as a path separator. It is shown as a url instead of needed / separator for urls. Works as is under Unix, but clearly not on Windows.

Model get_<field>_url() method gives the url with correct path separator. Perhaps it should be used in the link instead of value.

Change History (3)

comment:1 by rudyryk <alexey.rudy@…>, 16 years ago

As I know, it's better to define all paths with '/' not depending on platform - it is valid. I do so and have no such problem as you described.

comment:2 by edgarsj, 16 years ago

Django creates the file path with '\' itself in database after uploading the file via admin.

comment:3 by Ramiro Morales, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top