简体   繁体   English

如何在我的Django模板上下文中获得“debug”变量?

[英]How do I get a “debug” variable in my Django template context?

According to this SO post: 根据这篇SO帖子:

How to check the TEMPLATE_DEBUG flag in a django template? 如何检查django模板中的TEMPLATE_DEBUG标志?

if: 如果:

  • A) my settings.py file has: A)我的settings.py文件有:

TEMPLATE_CONTEXT_PROCESSORS = ['django.core.context_processors.debug',...

  • and B) I use a RequestContext (as opposed to a Context) 和B)我使用RequestContext(而不是Context)

I should have a "debug" variable to my template context. 我的模板上下文应该有一个“debug”变量。 However, I don't: when I do {{debug}} in a template, it renders as nothing (""). 但是,我没有:当我在模板中执行{{debug}}时,它会呈现为空(“”)。

Is there anything else I'm missing that is necessary to get a "debug" var in the template context? 在模板上下文中获取“debug”var是否还有其他我想要的东西?

您还需要确保请求的IP地址在您的设置中的INTERNAL_IPS中(您可能没有设置): https//docs.djangoproject.com/en/2.1/ref/templates/api/#django-模板上下文处理器调试

暂无
暂无

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

相关问题 如何在django-cms模板中使用调试变量? - How do I use the debug variable in a django-cms template? Django:如何在我的模板的模型中显示此变量信息 - Django: How do I display this variable information in models to my template 如何在Django中将View上下文变量评估为Template变量? - How can I evaluate a View context variable as a Template variable in Django? 如何在我的settings.py中的DEBUG变量在Django的模板中可用? - How do I make the DEBUG variable in my settings.py available in my templates in Django? 如何将上下文名称传递到模板 html django 中的 url 调用中 - How do I pass a context name into a url call in my template html django 如何在Django模板中比较上下文变量和SQL ID? - How can i compare a context variable with a SQL ID in a Django template? 如何从 django 模板的上下文中检索列表 - How can I retrieve a list from context in my django template 如何在Django的模板中显示views输出变量? - How do I display my views output variable in my template in Django? 我如何让django-debug-toolbar只显示在python托管的我的IP地址上的任何地方? - How do I get django-debug-toolbar to only display on my ip address hosted on python anywhere? 如何在views.py POST方法中获取与字典键相对应的编辑值,并将其作为上下文变量传递到Django模板中? - How can I get the edited values corresponding to the keys of a dictionary in views.py POST method, passed as a context variable in Django template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM