Python 视图不';不显示列表
从列表中分离索引并创建,但现在 当我创建产品时,它不会列出,也不会显示“编辑”和“更新”按钮。 创建扩展了索引的视图 这是index.htmlPython 视图不';不显示列表,python,html,css,django,Python,Html,Css,Django,从列表中分离索引并创建,但现在 当我创建产品时,它不会列出,也不会显示“编辑”和“更新”按钮。 创建扩展了索引的视图 这是index.html <!DOCTYPE html> <html><head> <title>Mis Productos</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/boo
<!DOCTYPE html>
<html><head>
<title>Mis Productos</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head><body>
<div class="container text-center pt-5">
<h1>Hola</h1>
<p>Inventario de productos</p>
<div class='jumbotron'>
<center>
<div class="text-left" style="max-width:500px">
<form action="{% url 'index' %}" method="post">
{% csrf_token %}
{% for field in register_form %}
<div class='form-group'>
<label for="{{ field.name }}">{{ field.label }}</label>
{{ field }}
</div>
{% endfor %}
<br>
<center><a href="{% url 'create' %}" class="btn btn-success btn-lg">Registrar producto</a></center>
</form>
</div>
{% block content %}
</center>
<br>
<table class="table table-striped table-bordered">
<thead class="thead-dark">
<tr>
<th>#</th>
<th>Nombre</th>
<th>Telefono</th>
<th>Fecha de nacimiento</th>
<th>Email</th>
</tr>
</thead><tbody>
{% for producto in productos %}
<tr>
<td>{{ producto.id }}</td>
<td>{{ producto.nombre }}</td>
<td>{{ producto.precio }}</td>
<td>{{ producto.fecha_de_vencimiento }}</td>
<td>{{ producto.codigo_barras }}</td>
<td><a href="update/{{producto.id}}" class="btn btn-info" id = '{{producto.id}}'>edit</a></td>
<td><a href="delete/{{producto.id}}" class="btn btn-danger" id = '{{producto.id}}'>delete</a</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div><script src="https://code.jquery.com/jquery-
3.3.1.slim.min.js" integrity="sha384
-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jiz
o" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/um
d/popper.min.js" integrity="sha384-
ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"> </script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/boot
strap.min.js" integrity="sha384-
ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULT
y" crossorigin="anonymous"></script>
{% endblock %}
</body>
</html>
错误产品
赫拉
产品发明
{%csrf_令牌%}
{注册表中字段的%u形式%}
{{field.label}
{{field}}
{%endfor%}
{%block content%}
#
名义
电传
纳西门托酒店
电子邮件
{productos%中producto的%s}
{{producto.id}
{{producto.nombre}}
{{producto.precio}}
{{producto.fecha_de_venciiento}
{{producto.codigo_barras}
删除您正在使用的:{%extends'producto/inicio.html%}是否正确?看起来你想扩展index.html,我想扩展index.html
{% extends 'producto/inicio.html' %}
{% block content %}
<center>
<h1 class="display-3" style="background-color:#000000;color:#FFFF99;">
Crear Productos</h1>
<form method = 'POST' enctype="multipart/form-data">
{% csrf_token %}
<table class = 'w-50 table table-light' style="border-radius:10px;background-color:#FFFF99;">
{% for field in create_form %}
<tr><th>{{field.label}}</th>
<td>{{ field }}</td>
</tr>
{% endfor %}
</table>
<button type="submit" class="btn btn-lg btn-warning">Submit</button>
</form>
</center>
{% endblock %}