[Answer]-How to display fields of a M2M relation

1👍

I think you would try

{% for element in user_data.follows.all %}
    <p>{{element.username}}</p>
    <p>{{element.profile.website}}</p>
    <p>{{element.profile.avatar}}</p>
{% endfor %}

element is an instance of User and not an instance of Profile.
But you can still retrieve the associated Profile instance by writing

element.profile

because it’s a One-To-One relationship (OneToOneField or ForeignKey(unique=True))

Leave a comment