我正在使用Django 3.1
我已配置了URL,以便可以在模板中正确使用以下内容:
<li><a href="{% url 'sitemember:profile' 'bobby' %}">{{ user.username }} </a></li>
user.username解析为“ bobby”的位置
如何将变量传递user.username
给url()
标记,以便URL正确解析为:
https:// localhost:/ user / bobby(作为示例)
您可以在{% url … %}
模板标签[Django-doc]中指定:
<a href="{% url 'sitemember:profile' user.username %}">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句