Olá! Tenho o seguinte codigo abaixo querendo fazer uma paginação do resultado de registro da tabela na cliente.html. Os companheiros poderiam me ajudar a conseguir isso.
**Moldel,py**
from django.db import models
class Cliente(models.Model):
codigo = models.AutoField(primary_key=True)
cl_codigo = models.TextField(max_length=3)
cl_descri = models.TextField(max_length=60)
cl_endere = models.TextField(max_length=70)
cl_bairro = models.TextField(max_length=30)
**View.py**
from django.shortcuts import render
from projeto_cpag.conexao import abreconexao, fechaconexao
from .models import Cliente
def cliente(request):
con = abreconexao("localhost","root", "","gestorweb")
if con.is_connected():
cursor = con.cursor(dictionary=True)
cursor.execute('select codigo, cl_descri, cl_endere, CL_bairro from cliente order by cl_descri limit 0, 7')
listcliente = cursor.fetchall()
fechaconexao(con)
return render(request, "cadastro/cliente.html", {"listcliente": listcliente} )
E finalmente a minha template Html
**cliente.html**
{% extends 'principal/base.html' %}
{% block conteudo %}
<div class="table-responsive">
<div>
<table class="table table-dark table-striped" >
<caption class="poscaption" >
Clientes Cadastrados
</caption>
<thead>
<tr>
<th>Codigo</th>
<th>Nome</th>
<th>Situacao</th>
<th>Loja</th>
</tr>
</thead>
<tbody>
{%for listcliente in listcliente %}
<tr>
<td>{{listcliente.codigo}}</td>
<td>{{listcliente.cl_descri}}</td>
<td>{{listcliente.cl_telefone}}</td>
<td>{{listcliente.cl_loja}}</td>
<td>
<a href="" class="btn btn-warning btn-sm" title="Editar">Ed</a>
<a href="" class="btn btn-danger btn-sm" title="Deletar">De</a>
</td>
</tr>
{%empty%}
<tr>
<td colspan="4">Nenhum registro encontrado</td>
</tr>
{%endfor%}
</tbody>
</table>
</div>
</div>
{% endblock %}