执行检查,以查看用户是否正在参加与否。 我如何通过上下文变量is_attending
到模板没有得到一个语法错误'is_attending': context['is_attending']
支票基本上是造型的div和诸如此类的东西。 我究竟做错了什么?
模板:
{% for event in upcoming %}
{% registration %}
{% if is_attending %}
Registered!
{% else %}
Register button
{% endif %}
yadda yadda divs...
{% endfor %}
filters.py
@register.inclusion_tag('events/list.html', takes_context=True)
def registration(context, event):
request = context['request']
profile = Profile.objects.get(user=request.user)
attendees = [a.profile for a in Attendee.objects.filter(event=event)]
if profile in attendees:
'is_attending': context['is_attending']
return is_attending
else:
return ''
谢谢!