为什么我不能在Django模板视图中做连字符? [英] Why can't I do a hyphen in Django template view?

查看:77
本文介绍了为什么我不能在Django模板视图中做连字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{{profile.first-name.value}}

我的变量仅是连字符...我希望可以做 first_name ,但是很多变量都是连字符。
但是,由于这个问题,我无法在模板中显示变量。为什么?

My variable is hypeh only...I wish I could do first_name, but many variables are hyphens. However, due to this problem, I can't display my variables in the template. Why?

推荐答案

连字符是Python中的运算符。如果您将所有的连字符替换为下划线,效果会更好。

The hyphen is an operator in Python. It would work better if you swapped all hyphens for underscores.

这篇关于为什么我不能在Django模板视图中做连字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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