无效的块标记:'bootstrap_icon'、应为 'elif'、'else' 或 'endif'
Invalid block tag: 'bootstrap_icon', expected 'elif', 'else' or 'endif'
我尝试了很多但无法修复此错误。
TemplateSyntaxError at /myrestaurants/restaurants/1/
Invalid block tag: 'bootstrap_icon', expected 'elif', 'else' or 'endif'
Request Method: GET
Request URL: http://127.0.0.1:8000/myrestaurants/restaurants/1/
Django Version: 1.8.7
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag: 'bootstrap_icon', expected 'elif', 'else' or 'endif'
Exception Location: /usr/lib/python2.7/dist-packages/django/template/base.py in invalid_block_tag, line 395
Python Executable: /usr/bin/python
Python Version: 2.7.12
Python Path:
['/home/vaibhav/Desktop/projects/myrecommendations',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/vaibhav/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/gtk-2.0']
Server time: Thu, 1 Feb 2018 16:53:44 +0000
实际上我想显示一个 table,其中第一列应该显示 customers.Here 给出的星号是我的代码部分,我在其中遇到错误:-
{% if restaurant.restaurantreview_set.all != 0 %}
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Rating</th>
<th>Comment</th>
<th>User</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for review in restaurant.restaurantreview_set.all %}
<tr>
<td>{% if review.rating == 1%}{% bootstrap_icon "star" %}
{% elif review.rating == 2%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 3%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 4%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 5%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% endif %}</td>
<td>{{ review.comment }}</td>
<td>{{ review.user }}</td>
<td>{{ review.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>Please post the review.</p>
{% endif %}
我尝试了很多事情,但无法succeed.Please提供帮助。
提前致谢。
{% load bootstrap3 %} -- add this line at the top of your layouts file
{% if restaurant.restaurantreview_set.all != 0 %}
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Rating</th>
<th>Comment</th>
<th>User</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for review in restaurant.restaurantreview_set.all %}
<tr>
<td>{% if review.rating == 1%}{% bootstrap_icon "star" %}
{% elif review.rating == 2%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 3%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 4%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 5%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% endif %}</td>
<td>{{ review.comment }}</td>
<td>{{ review.user }}</td>
<td>{{ review.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>Please post the review.</p>
{% endif %}
我尝试了很多但无法修复此错误。
TemplateSyntaxError at /myrestaurants/restaurants/1/
Invalid block tag: 'bootstrap_icon', expected 'elif', 'else' or 'endif'
Request Method: GET
Request URL: http://127.0.0.1:8000/myrestaurants/restaurants/1/
Django Version: 1.8.7
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag: 'bootstrap_icon', expected 'elif', 'else' or 'endif'
Exception Location: /usr/lib/python2.7/dist-packages/django/template/base.py in invalid_block_tag, line 395
Python Executable: /usr/bin/python
Python Version: 2.7.12
Python Path:
['/home/vaibhav/Desktop/projects/myrecommendations',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/vaibhav/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/gtk-2.0']
Server time: Thu, 1 Feb 2018 16:53:44 +0000
实际上我想显示一个 table,其中第一列应该显示 customers.Here 给出的星号是我的代码部分,我在其中遇到错误:-
{% if restaurant.restaurantreview_set.all != 0 %}
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Rating</th>
<th>Comment</th>
<th>User</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for review in restaurant.restaurantreview_set.all %}
<tr>
<td>{% if review.rating == 1%}{% bootstrap_icon "star" %}
{% elif review.rating == 2%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 3%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 4%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 5%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% endif %}</td>
<td>{{ review.comment }}</td>
<td>{{ review.user }}</td>
<td>{{ review.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>Please post the review.</p>
{% endif %}
我尝试了很多事情,但无法succeed.Please提供帮助。 提前致谢。
{% load bootstrap3 %} -- add this line at the top of your layouts file
{% if restaurant.restaurantreview_set.all != 0 %}
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Rating</th>
<th>Comment</th>
<th>User</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for review in restaurant.restaurantreview_set.all %}
<tr>
<td>{% if review.rating == 1%}{% bootstrap_icon "star" %}
{% elif review.rating == 2%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 3%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 4%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}
{% elif review.rating == 5%}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% bootstrap_icon "star" %}{% endif %}</td>
<td>{{ review.comment }}</td>
<td>{{ review.user }}</td>
<td>{{ review.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>Please post the review.</p>
{% endif %}