Opened 15 years ago

Closed 15 years ago

#11858 closed (worksforme)

Named urls in url template tag resolved differently

Reported by: pdwhite@… 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

Change History (1)

comment:1 by Karen Tracey, 15 years ago

Resolution: worksforme
Status: newclosed

I cannot recreate this. Using exactly what you have specified, expect putting quotes around 'django.views.static.serve' to make it work:

    url(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': '/location/to/files'}, name='static'),

I get as output from the url tags you cite:

/site_media//css/style.css 
/site_media//css/style.css

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.

Note: See TracTickets for help on using tickets.
Back to Top