我正在关注template inheritance上的django文档,我认为我的代码是正确的,但它不起作用,模板people_index.html 未呈现。
我有三个模板,base.html,base_index.html,people_index.html,每个模板都继承了前一个模板。像这样:
base.html文件
{% include "base/header.html" %}
<body>
{% include "base/navbar.html" %}
{% include 'base/messages.html' %}
<div class="container container-content">
{% block content %}
{% endblock content %}
</div><!-- /.container -->
</body>
</html>
base_index.html
{% extends "base/base.html" %}
<h3 class="snps-slim-font">Index de {{ index_of }}</h3>
<div class="input-group"> <span class="input-group-addon">Filtrar</span>
<input id="filter" type="text" class="form-control" placeholder="Ingrese un criterio">
</div>
<table class="table table-hover table-condensed">
{% block table_content %}
{% endblock table_content %}
</table>
最后 people_index.html
{% extends "base/base_index.html" %}
{% block table_content %}
<thead>
<tr>
<th class="snps-slim-font">APELLIDOS</th>
<th class="snps-slim-font">NOMBRES</th>
<th class="snps-slim-font">DOCUMENTO</th>
<th class="snps-slim-font">CUIL</th>
<th class="snps-slim-font">ACCIONES</th>
</tr>
</thead>
<tbody class="searchable">
{% for person in object_list %}
<tr>
<td>{{ person.last_names }}</td>
<td>{{ person.first_names }}</td>
<td>{{ person.document_number }}</td>
<td>{{ person.cuil_number }}</td>
<td class="snps-text-align-center">
<a href="{% url 'people:person-detail' person.id %}" title="ver perfil"><i class="glyphicon glyphicon-eye-open" aria-hidden="true"></i></a> <a href="{% url 'people:person-update' person.id %}" title="editar perfil"> <i class="glyphicon glyphicon-edit" aria-hidden="true"></i></a></td>
</tr>
{% endfor %}
</tbody>
{% endblock table_content %}
如果有人问:
class PersonListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
model = Person
template_name = 'people/people_index.html'
permission_required = ('people.can_view_list')
def get_context_data(self, **kwargs):
context = super(PersonListView, self).get_context_data(**kwargs)
return context
感谢。
答案 0 :(得分:3)
在def userMove():
usersMove = input("Time to make your choice: ")
while usersMove not in ['rock', 'paper', 'scissors']:
print("That is not a valid")
usersMove = input("Time to make your choice: ")
return usersMove
中使用了
base.html
但在{% block content %}{% endblock %}
中你没有添加它们。尝试在base_index.html
中添加此块。