1👍
✅
With your database structure you will be able to get all the speakers and profiles associated with a company in your template, but you won’t be able to get a specific profile.
To get all the profiles you can use:
{% for invite in invites %}
{% for profile in invite.invited_to.company.profile_set.all %}
{{ profile.user.first_name }} {{ profile.user.last_name }}
{% endfor %}
{% endfor %}
This should give you the name for every profile that is in a company that has been invited.
You can do a similar thing to get all the speakers for a company.
{% for invite in invites %}
{% for profile in invite.speaker.company.profile_set.all %}
{{ profile.user.first_name }} {{ profile.user.last_name }}
{% endfor %}
{% endfor %}
Having a guess at what you’re trying to do, I imagine you actually want to either use {{ request.user }}
in your template to get the logged in user or to pass a profile object to the template.
Source:stackexchange.com