0
I’m young, and I’m still facing difficulties that might seem pretty simple to you. I decided for personal reasons to make an application in Django. It is a simple registration of people in a Mysql database using Django adminLTE, adminLTE_theme:
in models py.
from django.db import models
class Pessoas(models.Model):
nome = models.CharField(max_length=150, verbose_name='nome completo')
registro = models.IntegerField(verbose_name='número do registro')
class Meta:
managed = True
db_table = 'pessoas'
verbose_name = 'Filiado'
verbose_name_plural = 'Filiados'
def __str__(self):
return self.nome
in admin.py
from django.contrib import admin
from .models import Pessoas
@admin.register(Pessoas)
class PessoasAdmin(admin.ModelAdmin):
list_display = ('nome', 'registro')
When accessing the registration page in the administrative area, I would like to have a line (Row, or anything) that shows the number of the last registered record.
I tried to make a copy of the template change_form.html and direct to this html:
from django.contrib import admin
from .models import Pessoas
@admin.register(Pessoas)
class PessoasAdmin(admin.ModelAdmin):
list_display = ('nome', 'registro')
add_form_template = 'cad_filiado.html'
and in html:
{% block field_sets %}
<div class="row">
<table class="table table-striped">
<thead>
<tr>
<th>Pessoa</th>
<th>Registro</th>
</tr>
</thead>
<tbody>
{% for p in pessoas %}
<tr>
<td>{{ p.pessoa }}</td>
<td>{{ p.registro }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
I even copied the code from change_list_result.html in cad_affiliated.html and gives reverse_url error... tried several things, read and reread the documentation and found no answer. (Maybe the answer until it’s there, but I did not understand how to run)
You may wonder: why do you want this information on the registration page?
A: To maintain a pleasant usability, without having to search the records.
thank you for your patience.