开发者

How do return many to many values on a template

Hello guys I have a doubt in django templates, I have two models with m2m开发者_开发技巧 relationship, Students and Discipline.

Discipline, has the following fields: description Students, has the following fields: name, age and disciplina_set (m2m from Discipline)

For example one student signed up (Lucas 20) with the following disciplines (Django, Python and Javascript)

Now I want to return a table in my template with the data registered in a table

I can return all the normal data, but the only return it in courses I have is something like this:

how do I return the values in this table?

thanks


hy folks i do this and works =D :

{% for student in student_l %}  
    <tr id="row_{{student.id}}">
        <td>{{ student.id }} </td>   
        <td>{{ student.name }} </td>   
        <td>{{ student.age }} </td>   
        <td>{% for discipline in aluno.discipline_set.all %} {{> discipline.description }}, {% endfor %}</td>   
    </tr>
{% endfor %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜