2013-07-26 2 views
0

template.htmlпроблема, если условие цикла

В Джанго возможно проверить состояние, как это, я получаю сообщение об ошибке в этой строке (incident.other_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'" 

ответ

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%} 
Смежные вопросы