Code

Opened 5 years ago

Closed 5 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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.