Django - 我的模板中的Userprofile字段 [英] Django - Userprofile field in my template
本文介绍了Django - 我的模板中的Userprofile字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的模板中打印的变量:
{{request.user.get_profile()。phone}}
错误:
无法解析剩余部分:'().phone'from'request.user.get_profile()。phone'
发生了什么事?如何打印mu userprofile变量?
解决方案
尝试使用这个代码:
{{request.user.get_profile.phone}}
I am using UserProfile in my django app. It works very well in my view. But I am having some difficult to show the values in my template.
Variable that I am trying to print in my template:
{{ request.user.get_profile().phone }}
Error:
Could not parse the remainder: '().phone' from 'request.user.get_profile().phone '
Whats happened? How can I print mu userprofile variable?
解决方案
Try using this instead:
{{ request.user.get_profile.phone }}
这篇关于Django - 我的模板中的Userprofile字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文