0👍
If you want to do that in the template, just use the teamplayer_set like this:
{% if request.user in object.teamplayer_set.all %}
0👍
You have it 1-on-1, so it should be
players = TeamPlayer.object.all()
if request.user.player in players
# Do what you need to
or in template
{% if request.user.player in players %}
provided players
is sent to the template
When it’s one-on-one, it’s always user.player
to get related player and player.user
for the related user.
- [Django]-Urls.py redirect with URL reversal and parameters — is there any easier way?
- [Django]-How can I exclude rest-auth endpoint from the Django built-in API documentation?
- [Django]-Django auto logout and page redirection
- [Django]-Cannot concatenate 'str' and 'tuple' objects – Django – johnny cache
- [Django]-Django google maps
Source:stackexchange.com