Template django

0

I am currently developing a website with python and django , I have a table of educational offers and another table which has a many-to-many relationship with educational offerings, make the query in the database

ofertas = models.ManyToManyField(oferta_educativa, blank = True)

when consulting the data in the template

  

    {% for p in ofertas%}
       <tr>
            <td>{{forloop.counter}}</td>
            <td>{{p.sede.nombre}}</td>
            <td>{{p.jornada}}</td>
            <td>{{p.nivel}}</td>
            <td>{{p.grado}}</td>
        </tr>
    {% endfor %}

does not show the name of the headquarters to which this educational offer is assigned. how I do it to be able to show the name of that headquarters

    
asked by Daniel Ceron 05.09.2017 в 03:44
source

1 answer

0

Do you have any string method in the headquarters model? Try adding a string method to the headquarters model:

class Sede(models.Model):
    nombre_sede = models.CharField(maxlength=100)
    ...
    ...

    def __str__(self):
        return self.nombre_sede
    
answered by 09.01.2018 в 20:37