template.html
在django中可以检查这样的情况,我在这一行收到错误(incident.other_location或location)。
{%if newreport_tab and reportperson and incident.manual_date and media and followup and (incident.other_location or location) and incident.other_incident_type and types%}<a href="{% url incident.views.savereport %}">{% include "buttons/saveandclose.html" %}</a>{%else%}{% include "buttons/saveandclose.html" %}{%endif%}
我收到此错误
"TemplateSyntaxError at /report/savereport/
Could not parse the remainder: '(incident.other_location' from 'and(incident.other_location'"
答案 0 :(得分:2)
您不能使用()
(括号)来组合操作,而是可以遵循以下运算符的优先级:
在or
评估之前:
{%if newreport_tab and reportperson and incident.manual_date and media and followup and incident.other_location or location and incident.other_incident_type and types%}<a href="{% url incident.views.savereport %}">{% include "buttons/saveandclose.html" %}</a>{%else%}{% include "buttons/saveandclose.html" %}{%endif%}
or
评估后:
{%if newreport_tab and reportperson and incident.manual_date and media and followup and someresult and incident.other_incident_type and types%}<a href="{% url incident.views.savereport %}">{% include "buttons/saveandclose.html" %}</a>{%else%}{% include "buttons/saveandclose.html" %}{%endif%}