How can I display only selected options of a fild type ManyToMany - django

30 Views Asked by At

Good morning, I need to display the values selected in the manytomany field named "sfide" in a table I will build with html, how can I do it? thanks

I also attach the image of the class "Profilo" with the ManyToMany field "sfide" enter image description here

1

There are 1 best solutions below

1
Alemmo On BEST ANSWER

I found the answer:

            <table>
            <tr>
                <td>
                    <h4>Sfide Scelte</h4>
                </td>
            </tr>
            {% for sfida in user.profile.sfide.all %}
            <tr>
                <td>{{ sfida.sfida }}</td>
            </tr>
            {% endfor %}
        </table>