I saw similar questions but none of them solved my problem .
I have a simple template tag like this :
@register.simple_tag
def liked_by_user(post_id, user):
try:
PostModel.objects.get(pk=post_id).like_set.get(user=user)
return True
except:
return False
and i want to use this in an if statement like this :
{% if liked_by_user post.pk request.user %}
doing somethin...
{% else %}
doing somethin...
{% endif %}
what can i do ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With