Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22924 closed Cleanup/optimization (fixed)

MEDIA_URL needs TEMPLATE_CONTEXT_PROCESSORS

Reported by: raphael.herouart@… Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It could be useful for beginners like me to know that without adding:

"django.core.context_processors.media",

to your TEMPLATE_CONTEXT_PROCESSORS, you will not get MEDIA_URL in your template. I found it easily on stack overflow though.

But it was not here:

https://docs.djangoproject.com/fr/1.6/howto/static-files/

Attachments (1)

22924.diff (738 bytes ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Tim Graham, 10 years ago

I'm not sure that's the best page for mentioning this as there's no example of referring to uploaded files in templates.

There's a warning in the settings docs: "Be careful when you override settings, especially when the default value is a non-empty tuple or dictionary, such as MIDDLEWARE_CLASSES and TEMPLATE_CONTEXT_PROCESSORS. Make sure you keep the components required by the features of Django you wish to use."

I think if you had seen that, you'd probably have looked at the initial TEMPLATE_CONTEXT_PROCESSORS list and checked what each of them did. What do you think?

comment:2 by guardian, 10 years ago

I'm not sure, I think it is obvious to you that the problem is due to TEMPLATE_CONTEXT_PROCESSORS. But to a beginner, is obvious only what shows up using Google. And the two first pages that I found using "MEDIA_URL django" were the one you mentioned and the one I mentioned.

Also, even if the beginner is smarter than me and search for the template context processors,he'll google both "context_processors.media" or "django.core.context_processors.media", and find no explanation.

I thought static files was a better place to add some section about templates because it is more "focused", settings page looks like a big dictionary. But really it is up to you.

comment:3 by guardian, 10 years ago

oh... I just got what you meant. Actually, I don't remember having modified these settings. Maybe inadvertently. Sorry, English is not my mother tongue.

comment:4 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

How about the attached patch?

by Tim Graham, 10 years ago

Attachment: 22924.diff added

comment:5 by guardian, 10 years ago

Fine. It is perfect. Thanks a lot.

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 814bcc33951db8a469b9bba26fb021fc2d8ad480:

Fixed #22924 -- Added a note about MEDIA_URL in templates.

Thanks raphael.herouart at gmail.com

comment:7 by Tim Graham <timograham@…>, 10 years ago

In 890a2d632e173edfd2b70854b72dfbd0e1a2d92b:

[1.6.x] Fixed #22924 -- Added a note about MEDIA_URL in templates.

Thanks raphael.herouart at gmail.com

Backport of 814bcc3395 from master

comment:8 by Tim Graham <timograham@…>, 10 years ago

In f99267e5e6779d192959569155846f8b0ca5eb07:

[1.7.x] Fixed #22924 -- Added a note about MEDIA_URL in templates.

Thanks raphael.herouart at gmail.com

Backport of 814bcc3395 from master

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