I have a weird problem, I want to add a global query using context processors.
This is how I did it by following:
made a processor.py in my app as such:
from myproject.myapp.models import Foo
def foos(request):
return {'foos': Foo.objects.all()}
and at the end of my setting.py I have added this:
TEMPLATE_CONTEXT_PROCESSORS = ('myapp.processor.foos',)
Lastly I pass my view as this:
def index_view(request):
return render_to_response('index.html', {}, context_instance=RequestContext(request))
and at my index.html template:
<select id="select_foo">
{% for foo in foos %}
<option value="/{{ foo.slug }}">{{ foo.name }}</option>
{% endfor %}
</select>
And lastly my url:
(r'^$', 'myapp.views.index_view'),
My foos display without any problem, however my media_url and other contexts are gone.
What can be the issue
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…