Opened 16 years ago
Closed 16 years ago
#10232 closed (worksforme)
On development server, MEDIA_URL exists without setting context_instance. Works properly in mod_python.
Reported by: | chazmatazz | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Steps to repeat the problem:
- In settings.py set TEMPLATE_CONTEXT_PROCESSORS to include 'django.core.context_processors.media'
- In settings.py set MEDIA_URL to a non empty string e.g. '/media/'
- In views.py, run render_to_response _without_ setting context_instance.
- Have in the template used by render_to_response {{ MEDIA_URL }}
Expected:
{{ MEDIA_URL }} evaluates to '/media/'
What should happen
{{ MEDIA_URL }} evaluates to . This is what happens in mod_python.
Other notes
This is a bug in the development server. It's annoying because you think you have a working setup in development, but then you go to deploy and it's not working.
Note:
See TracTickets
for help on using tickets.
This report is a bit confusing because there is "Expected" and "What should happen" as opposed to "Expected" and "Actual Results" or "What happens" and "What should happen". Since your "Expected" seems to be, rather, "Unexpected", I'm guessing you meant "What happens" there. It is also unclear what you mean by "without setting context instance". You mean passing no context into render_to_response? Passing a Context but not a RequestContext? Bare bones snippets of code could have clarified here.
At any rate I cannot recreate a problem here. Using these views:
and this mq.tmpl:
only the mq2 view displays the MEDIA_URL value that is set in settings.py, as expected since the context processor that does this is documented to only affect RequestContexts. Tested using the development server on trunk r9817.