如何在默认过滤器中使用 django 变量作为文本
我有一个包含个人资料信息的字典,我用它来在 django 模板中显示个人资料详细信息。现在我想显示默认消息,以防特定信息不可用。 我知道我可以使用默认过滤器来完成此任务。但我所有的默认消息都存储为另一个字典。所以我想要这样的东西 -
<span>{{ profile.about|default:"{{ defaults.about }}" }}</span>
我无法使用上面的语法达到预期的结果。 任何有关正确方法的帮助将不胜感激。
I have a dictionary containing profile information which i am using to show profile details in django template. Now i want to display a default message in case a particular information is not available.
I know i can use default filter to accomplish this. But all my default messages are stored as another dictionary. so i want something like this -
<span>{{ profile.about|default:"{{ defaults.about }}" }}</span>
I am not able to achieve desired results using above syntax.
Any help on correct way will be really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)