Django

Code

Ticket #2532 (closed: wontfix)

Opened 4 years ago

Last modified 3 years ago

[patch] made media_url accessibly thru context_processor

Reported by: dummy@habmalnefrage.de Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

context_processor-media_url.diff (397 bytes) - added by dummy@habmalnefrage.de on 08/12/06 10:16:05.
django.core.content_processor.media_url

Change History

08/12/06 10:16:05 changed by dummy@habmalnefrage.de

  • attachment context_processor-media_url.diff added.

django.core.content_processor.media_url

08/17/06 22:46:34 changed by adrian

  • status changed from new to closed.
  • resolution set to wontfix.

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.

08/28/06 13:17:15 changed by treborhudson@gmail.com

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 settings.py, MEDIA_URL is set to a broken URL: MEDIA_URL = "http://www.djangoproject.com.com/m/" # <- 2 .com's in there But in the templates, it's hard coded as http://media.djangoproject.com/.

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.

05/03/07 09:41:04 changed by Marc Fargas <telenieko@telenieko.com>

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

05/03/07 09:42:41 changed by Marc Fargas <telenieko@telenieko.com>

  • stage changed from Unreviewed to Design decision needed.

Add/Change #2532 ([patch] made media_url accessibly thru context_processor)




Change Properties
Action