I am able to fetch these two values in the Django HTML template :
{{ user.get_username }}
{{ post.user }}
But when I use them further to compare their values in an IF condition, it doesn't work.
{%for post in post%}
<a href="{% url 'post_detail' post.id %}"><h1>{{post.title}}</h1></a>
<h2>{{post.content}}</h2>
<p>{{post.date}}</p>
{%if user.is_authenticated%}
<h3> {{ user.get_username }}</h3>
<h3> {{post.user}} </h3>
{%ifequal user.get_username post.user%}
<form action="{%url 'post_delete' post.id %}" method="POST">
{%csrf_token%}
<button type="submit">Delete</button>
</form>
{%endifequal%}
{%endif%}
{%endfor%}
I've also tried {% if user.get_username == post.user %} as well, but it didn't help either.
Please help. I need the delete button only against the posts of logged in user.