"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/
--
Ticket URL: <https://code.djangoproject.com/ticket/22924>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
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
[https://docs.djangoproject.com/en/1.6/ref/settings/ 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?
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:1>
Comment (by guardian):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:2>
Comment (by guardian):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:3>
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
How about the attached patch?
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:4>
Comment (by guardian):
Fine. It is perfect. Thanks a lot.
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"814bcc33951db8a469b9bba26fb021fc2d8ad480"]:
{{{
#!CommitTicketReference repository=""
revision="814bcc33951db8a469b9bba26fb021fc2d8ad480"
Fixed #22924 -- Added a note about MEDIA_URL in templates.
Thanks raphael.herouart at gmail.com
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"890a2d632e173edfd2b70854b72dfbd0e1a2d92b"]:
{{{
#!CommitTicketReference repository=""
revision="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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"f99267e5e6779d192959569155846f8b0ca5eb07"]:
{{{
#!CommitTicketReference repository=""
revision="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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22924#comment:8>