Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

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/' ?

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by magopian

  • Cc mathieu.agopian@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 3 years ago by chris.is.fun+django@…

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 Changed 3 years ago by magopian

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.

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.