Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#2532 closed enhancement (wontfix)

[patch] made media_url accessibly thru context_processor

Reported by: dummy@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I asked the users-list for a solution to access MEDIA_URL in templates. The simplest and general solution are 3 lines to make a own context_processor. Since this is a general issue for maybe a lot of others it comes in mind that is a possible feature for django.core.context_processors ?

Attachments (1)

context_processor-media_url.diff (397 bytes) - added by dummy@… 14 years ago.

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by dummy@…


comment:1 Changed 14 years ago by Adrian Holovaty

Resolution: wontfix
Status: newclosed

I'm marking this as a wontfix due to the slippery slope potential. If we added this, then people would want a context processor for another setting, and for another setting, and for another. We've already ruled out the idea of a "settings" context processor (see [1278]), so I'd recommend that people write their own two-line context processors if they really want this stuff.

comment:2 Changed 14 years ago by treborhudson@…

I agree that this should be there by default. I can understand the slippery slope argument, but this makes sense. Other settings being viewable at the template level do not.

What's the point of setting MEDIA_URL if you can't use it in the templates? Where does it ever get used?

I can see that either a person is going to make their own context processor, or they're going to repeat themselves and list the absolute URL in their templates as well as in the settings (which violates the DRY principle).

I checked what the Django website does currently and it's confusing. In, MEDIA_URL is set to a broken URL:
MEDIA_URL = "" # <- 2 .com's in there
But in the templates, it's hard coded as

This makes me thing MEDIA_URL is useless. I'd much prefer setting it once and having an easy way to use it in the templates.

comment:3 Changed 13 years ago by Marc Fargas <telenieko@…>

More on #1278 with patch, docs and so on...

comment:4 Changed 13 years ago by Marc Fargas <telenieko@…>

Triage Stage: UnreviewedDesign decision needed
Note: See TracTickets for help on using tickets.
Back to Top