1👍
Use RequestContext()
while passing context to template. It will add user
context parameter , then you can compare it in your template as
{% for likes in forum.likes.all %}
{% if user != likes.user %}
<li><a href="/get/{{likes.user}}">{{likes.get_full_name}}</a></li>
{%endif%}
{% endfor %}
0👍
Can you try something like that ?
{% for likes in forum.likes.all %}
{% if user != likes.user %}
<li><a href="/get/{{likes.user}}">{{likes.get_full_name}}</a></li>
{% endif %}
{% endfor %}
👤Kayf
- [Answer]-Image File upload with Django form using jQuery
- [Answer]-Serialize python dataDict to json object
- [Answer]-Required and Optional Field in Django Formset
0👍
I had to compare it with fullname, as I was displaying the users full name in the list. So, this was the solution:
{% for likes in forum.likes.all.reverse %}
{% if user.get_full_name != likes.get_full_name %}
<li><a href="/get/{{likes.user}}">{{likes.get_full_name}}</a></li>
{% endif %}
{% endfor %}
Hope this will be helpful to someone as it was for me. And thanks for all those who helped me!
Source:stackexchange.com