Ticket #7415: 7415-filefield-url-admin-windows.diff
File 7415-filefield-url-admin-windows.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/django/contrib/admin/widgets.py
3 3 """ 4 4 5 5 import copy 6 import urllib 6 7 7 8 from django import newforms as forms 8 9 from django.newforms.widgets import RadioFieldRenderer … … 88 89 from django.conf import settings 89 90 output = [] 90 91 if value: 91 output.append('%s <a target="_blank" href="%s %s">%s</a> <br />%s ' % \92 (_('Currently:'), settings.MEDIA_URL, value, value, _('Change:')))92 output.append('%s <a target="_blank" href="%s">%s</a> <br />%s ' % \ 93 (_('Currently:'), urllib.pathname2url('%s%s' % (settings.MEDIA_URL, value)), value, _('Change:'))) 93 94 output.append(super(AdminFileWidget, self).render(name, value, attrs)) 94 95 return mark_safe(u''.join(output)) 95 96 -
django/tests/regressiontests/admin_widgets/models.py
50 50 >>> print conditional_escape(w.render('test', 'test')) 51 51 Currently: <a target="_blank" href="%(MEDIA_URL)stest">test</a> <br />Change: <input type="file" name="test" /> 52 52 53 In Windows, make sure that backward slashes are turned into forward slashes in the url. 54 >>> w = AdminFileWidget() 55 >>> print conditional_escape(w.render('testname', 'path\\\\file')) 56 Currently: <a target="_blank" href="%(MEDIA_URL)spath/file">path\\file</a> <br />Change: <input type="file" name="testname" /> 57 53 58 >>> band = Band.objects.create(pk=1, name='Linkin Park') 54 59 >>> album = band.album_set.create(name='Hybrid Theory') 55 60