Hello team,
I need a little help from you. I am writing a very basic webpage using Django.
I need to show some data in a table view, that works ok. The challenge I have is that I need to show a column “status_ind” which could have 1 or 0 values; but instead of showing up 1 or 0, I want to show Active or Inactive respectively.
Basically, the idea is to use an “If” statements on the HTML template. But I am getting this error when running the app:
TemplateSyntaxError at….
Invalid block tag on line 55 ‘else’, expected ‘empty’ or ‘endofr’. Did you forget to register or load this tag? See image enclosed.
I read the post below but not able to fix the erro
This is the code that I am using:
<table>
<thead>
<tr>
<th>ID Area</th>
<th>Codigo da Area</th>
<th>Nome da Area</th>
<th>Codigo SAP</th>
<th>Data de criação</th>
<th>Criado por</th>
<th>Data de modificação</th>
<th>Modificado por</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for area in myarea %}
<tr>
<td>{{ area.area_id }}</td>
<td>{{ area.area_code }}</td>
<td>{{ area.area_name }}</td>
<td>{{ area.sap_area_cd }}</td>
<td>{{ area.created_on }}</td>
<td>{{ area.created_by }}</td>
<td>{{ area.last_modified_on }}</td>
<td>{{ area.last_modified_by }}</td>
<td>
{ % if area.status_ind == '1' % }
Active
{% else %}
Inactive
{% endif %} </td>
</tr>
{% endfor %}
</tbody>
</table>
I also tried to writing “Active” & “Inactive” between Quotation Marks and single quote but not succsses,
any advice will be really appreciated.