gpt4 book ai didi

python - 模板语法错误 : 'with' expected with atleast one variable assignment

转载 作者:太空宇宙 更新时间:2023-11-03 12:45:50 27 4
gpt4 key购买 nike

我正在尝试通过 GET 方法将模板中的 meeting 对象的数据发送到 View 。为了给属性 meeting.date 一个更简单的别名,即 date 我使用了 with 模板标签。但它以 TemplateSyntaxError 结束。

urls.py

url(r'^meeting/$', meeting_display, name="meeting"),

views.py

def meeting_display(request):
date = request.GET.get('date')

ob_mem = memo.objects.get(subject='Meeting', rcv_username=username, date=date)
ob_mee = memo.meeting_set.all()

variables = RequestContext(request, {
'meeting': ob_mee,
})
return render_to_response('meeting_display.html', variables)

meeting_display.html

{% for meeting in meeting_f %}
<div class="list">
{% with date = meeting.date %}
<a href="{% url meeting %}?date={{date}}">{{ date }}:{{meeting.venue}}{{meeting.time}}</a>
{% endwith %}
</div>
{% endfor %}

最佳答案

= 两边不应有空格。要么使用

{% with date=meeting.date %}

the old syntax :

{% with meeting.date as date %}

关于python - 模板语法错误 : 'with' expected with atleast one variable assignment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36231619/

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