gpt4 book ai didi

django - 模板渲染期间出错/无法解析某些字符

转载 作者:行者123 更新时间:2023-12-04 15:16:39 25 4
gpt4 key购买 nike

我试图获取每个配置文件的个人信息,当运行服务器并转到帐户/配置文件时,我发现了这个错误:

无法解析某些字符:|% with website=profile.website| |默认值:""%

{% extends 'base.html' %}

{% block title %}Profile{% endblock %}

{% block content %}

<h1>
{{ user.get_null_name }} (@{{ user.username }})
</h1>

{% with profile=user.profile %}
{% if profile %}
<h2>
{{ profile.persona }}
</h2>
<div>
{{ profile.bio|default:"" }}
</div>
<div>
{{ % with website=profile.website | default:"" % }}
<a href="{{website}}">{{website}} </a>
{% endwith %}
</div>
<br/>
<div>
Interest:
{% for Interest in profile.interest.all %}
<span>
{{ interest.name }}{% if not forloop.last %}, {% endif %}
</span>
{% endfor %}
</div>
{% endif %}
{% endwith %}


{% endblock %}

最佳答案

模板标签使用双大括号({{ … }}),而是使用单个大括号, % 紧跟其后(所以 {% … %})。模板中的 {% with … %} block 使用双大括号:

<b>{%</b> with website=profile.website|default:'' <b>%}</b>

{% endwith %}

关于django - 模板渲染期间出错/无法解析某些字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64211049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com