Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15913 closed Uncategorized (invalid)

trailing slash

Reported by: chris.is.fun+django@… Owned by: nobody
Component: Uncategorized Version: 1.3
Severity: Normal Keywords:
Cc: mathieu.agopian@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

http://docs.djangoproject.com/en/1.0/howto/static-files/

For example, if we have a line in settings.py that says:

STATIC_DOC_ROOT = '/path/to/media'

Doesn't this need to be STATIC_DOC_ROOT = '/path/to/media/' ?

Change History (3)

comment:1 by Mathieu Agopian, 14 years ago

Cc: mathieu.agopian@… added
Resolution: invalid
Status: newclosed

According to the line 46 in django/views/static.py file, os.path.join is used to glue the document_root and the file path that needs to be served.

As os.path.join doesn't care about a trailing slash when gluing, I believe the trailing slash for the document_root isn't mandatory.
After a quick test, I can also confirm this behavior: with or without a trailing slash, it works as expected.

I'll thus close this ticket as invalid, but please, if you feel this should definitely be changed, reopen it and explain why !

comment:2 by chris.is.fun+django@…, 14 years ago

OK. I just noticed that the comments in settings.py suggest that the other similar extensions need to be '/x/y/z/' rather than 'x/y/z'. I don't know anything about os.path.join.

Why would the other paths need a trailing slash? Don't they use os.path.join as well?

comment:3 by Mathieu Agopian, 14 years ago

I can see only one reference about a mandatory trailing slash, and it's for ADMIN_MEDIA_PREFIX. I believe in the admin templates, they use it "as is", eg:

    <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />

Note the "missing" slash before "css", thus the need of the trailing slash in this case for ADMIN_MEDIA_PREFIX.

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