I have these two models
class Comunidad(models.Model):
rut = models.IntegerField(primary_key=True)
nombre = models.CharField(max_length=50)
email = models.CharField(max_length=50)
direccion = models.CharField(max_length=70)
def __str__(self):
return str(self.rut)
class Meta:
managed = False
db_table = 'comunidad'
class Asiste(models.Model):
id_capacitacion = models.ForeignKey('Capacitacion', models.DO_NOTHING, db_column='id_capacitacion', primary_key=True)
rut = models.ForeignKey('Comunidad', models.DO_NOTHING, db_column='rut')
fecha = models.DateField()
class Meta:
managed = False
db_table = 'asiste'
unique_together = (('id_capacitacion', 'rut'),)
and in a listview I want to list all of it in this case the id the rut and date but also I want next I see the name associated with the rut that obviously this name I find in my model 'Community', this is my listview
class persona_lista(ListView):
model = Asiste
template_name = 'asistencia.html'
and my template would be this way
{% for persona in object_list %}
<tr>
<th scope="row">{{persona.id_capacitacion }}</th>
<td>{{persona.rut }}</td>
<td>{{persona.fecha }}</td>
</tr>
{%endfor%}
I do not know how to add the column of the name associated with the rut, rut would be the id of each person.