Opened 15 years ago
Closed 15 years ago
#11858 closed (worksforme)
Named urls in url template tag resolved differently
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using a url tag, if you specify the view of the url with no trailing slash in the regex, it will render as a url with no trailing slash.
When using the url tag with a url's name, it will render with a trailing slash.
Example:
urls.py:
url(r'^site_media/(?P<path>.*)$', django.views.static.serve, {'document_root': '/location/to/files'}, name='static'),
template.html:
1. {% url static '/css/style.css' %} #Ends up as /site_media/css/style.css/ 2. {% url django.views.static.serve '/css/style.css' %} # /site_media/css/style.css
Note:
See TracTickets
for help on using tickets.
I cannot recreate this. Using exactly what you have specified, expect putting quotes around 'django.views.static.serve' to make it work:
I get as output from the url tags you cite:
Which match each other but neither of the ones you specify. However they look 'right' given what's been defined since the slash between site_media and css is present in both the pattern and the arguments to the url tag. What you have specified here doesn't seem to quite match whatever it is you are actually doing.