如何在模板中打印上下文内容? [英] How to print context content in the template?

查看:59
本文介绍了如何在模板中打印上下文内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从模板代码中打印或遍历上下文中可用的所有变量?

How can I print or iterate over all the variables available in the context from the template code?

我了解 {%debug%} ,但是其中包含太多信息.我只想打印当前上下文中可用的变量名.

I know about {% debug %} but it contains too much information. I'd just like to print variable names available in the current context.

是否有一种无需编写自定义标签的方法?

Is there a way to do this without writing custom tag?

推荐答案

使用 Django调试工具栏-在模板"选项卡上为您提供此信息,以及其他一系列有用的调试信息.

Use the Django debug toolbar - gives you this on the Templates tab, along a whole range of other useful debugging information.

这篇关于如何在模板中打印上下文内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆