Opened 14 years ago
Closed 13 years ago
#14792 closed Cleanup/optimization (invalid)
error in the default for TEMPLATE_CONTEXT_PROCESSORS
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | settings TEMPLATE_CONTEXT_PROCESSORS |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In this page, a list of context processors is given as the default for TEMPLATE_CONTEXT_PROCESSORS. But the generated settings file does not have TEMPLATE_CONTEXT_PROCESSORS at all. So either the default is set as empty, or the generated settings file should have the default values.
Change History (7)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
actually I noticed this problem because request was not available in the template even though I was passing it through RequestContext. It only became available when I added the requisite TEMPLATE_CONTEXT_PROCESSOR in settings.py. Apparently it does not take it from global_settings.py. I have seen this on about 4 sites in different locations and platforms. Just looked at global_settings.py and find that 'django.core.context_processors.request' has been commented out - that looks like the source of my problem.
comment:3 by , 14 years ago
The fact that the 'request' context processor is missing in global_settings.py is not a bug. The default list of context processors is the same as that in the docs. Apps that require the 'request' context processor need to state that they do. I guess the reason it is there and commented out is to make it easy for people to copy/paste and add it. The project template should probably have the same thing.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
follow-up: 6 comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
UI/UX: | unset |
Since this comes up at least a couple of times a week on IRC, and seems to me a pretty common requirement, why not just uncomment it and add that fact to the docs?
comment:6 by , 13 years ago
Replying to lawgon:
actually I noticed this problem because request was not available in the template even though I was passing it through RequestContext. It only became available when I added the requisite TEMPLATE_CONTEXT_PROCESSOR in settings.py. Apparently it does not take it from global_settings.py. I have seen this on about 4 sites in different locations and platforms. Just looked at global_settings.py and find that 'django.core.context_processors.request' has been commented out - that looks like the source of my problem.
Exactly, and what you'd need to do to solve that is what Luke suggested: Copy the default value from global_settings.py
or from the TEMPLATE_CONTEXT_PROCESSORS setting documentation and customize its value for your needs.
Replying to lawgon:
Since this comes up at least a couple of times a week on IRC, and seems to me a pretty common requirement, why not just uncomment it and add that fact to the docs?
It is not clear to me which is exactly the issue that comes up at least a couple of times a week on IRC?
comment:7 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Closing this because it doesn't appear to be a bug.
This isn't technically an error - if settings.py doesn't have TEMPLATE_CONTEXT_PROCESSORS it is taken from django/conf/global_settings.py, which does set it to the list given in the documentation.
The issue is that if you need to add something to TEMPLATE_CONTEXT_PROCESSORS, you need to copy from global_settings.py and then change. There are other similar settings for which we do this (like FILE_UPLOAD_HANDLERS, IGNORABLE_404_ENDS), but changing TEMPLATE_CONTEXT_PROCESSORS is probably going to be more common, and I imagine it would be more common than things like STATICFILES_FINDERS which is in the project template, so we should include this.