简体   繁体   English

Django 1.3 - RequestContext 不呈现到模板

[英]Django 1.3 - RequestContext not rendering to template

I am trying to simply render {{ request.user }} from my base template and for whatever reason it is not rendering anything.我试图从我的基本模板中简单地渲染 {{ request.user }} 并且无论出于何种原因它都没有渲染任何东西。 I have even tested trying to return {{ request }} to no avail.我什至测试过尝试返回 {{ request }} 无济于事。

I am currently using django-annoying to render to the template (render_to) and have tried to switch back to using django.templates.RequestContext and that hasn't worked either.我目前正在使用 django-annoying 渲染到模板 (render_to) 并尝试切换回使用 django.templates.RequestContext 并且这也没有奏效。

I have a feeling it has something to do with caching, but I have edited my template to show test - {{ request }} and "test - " shows up just fine.我感觉它与缓存有关,但我已经编辑了我的模板以显示 test - {{ request }} 并且“test -”显示得很好。

I have also tried to upgrade my django to 1.4 alpha to see if it resolves my issue.我还尝试将我的 django 升级到 1.4 alpha,看看它是否能解决我的问题。

This does not send the request to the template这不会将请求发送到模板

@render_to('profile/index.html')
def home(request):
    return {}

This works这有效

@render_to('profile/index.html')
def home(request):
    return {'request': request}

However, if I pass 'request': request into the template everything works.但是,如果我将 'request': request 传递到模板中,一切正常。

Link to settings.py链接到settings.py

I can give any more information that is requested.我可以提供任何要求的更多信息。

You need to add the django.core.context_processors.request context processor.您需要添加django.core.context_processors.request上下文处理器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM