0
template inheritanceのdjangoドキュメントに従っていますが、私のコードは正しいとは思うが動作しません。テンプレートpeople_index.htmlはレンダリングされません。Djangoテンプレートの継承がレンダリングされない
私は3つのテンプレート、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
ありがとう。 base.html
で