Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#11991 closed (wontfix)

Inconsistent MEDIA_URL values

Reported by: anonymous Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The documentation states the following:

URL that handles the media served from MEDIA_ROOT. Example: "http://media.lawrence.com"

Note that this should have a trailing slash if it has a path component.

Good: "http://www.example.com/static/" Bad: "http://www.example.com/static"

Why does a path component need to have a trailing slash but a domain doesn't?

We should pick one of these forms, as changing the value affects other areas (like the FileField.url attribute).
I, personally, think the slash-less form makes templates look better:

<a href="{{ MEDIA_URL }}/bla.js">...</a>

Versus:
<a href="{{ MEDIA_URL }}bla.js">...</a>

Change History (5)

comment:1 Changed 5 years ago by russellm

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

This isn't something we can change easily. The conventions for MEDIA_URL and MEDIA_ROOT are well established now. Unless you have a proposal for how we can make this change completely transparent, I'm marking wontfix.

comment:2 Changed 5 years ago by jezdez

I believe this is related to #12323 which proposes to introduce a separate setting pair STATIC_ROOT/STATIC_URL to differentiate between media files used by forms and widgets (e.g. provided by 3rd party apps) and user generated media files (e.g. file uploads).

comment:3 Changed 4 years ago by anonymous

  • milestone changed from 1.2 to 1.3

russellm, what difference would it make? Are these values being used by components other that the templates and the file upload field?

comment:4 Changed 4 years ago by jezdez

I could see a way to make this work by having the settings module check those values and append a slash if needed (yeah, I want those settings to having a trailing slash). Alternatively this could be fixed in the context processor or get_staticfiles_prefix template tag now.

comment:5 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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