django template language – if statement issues

i am kind of new to django and i ran into a problem i couldnt find a solution to. In a template i render data from a custom context processor. There i use a for loop over all the queried items and a if statement, that checks that the data belongs to the person that is currently logged in:

{% for item in all_soli_accs %}
    {% if item.owner == request.user.get_username %}
        <a href="{% url 'url-soli-acc' item.soli_acc %} ">
            {{ item.soli_acc }}   
        </a>
    {% endif %}
{% endfor %}

Weirdly, the if statement doesnt return "true", when it is supposed to. The rendering doesnt output anything. In order to debug it, i tried to render {{item.owner}} and {{request.user.get_username}} and check if there are errors. But rendered as a variable, they return the same output, which lets me assume that it is all fine. I am confused. Does anyone has a solution to that? Do you need further information?

best regards

>Solution :

Use

request.user.username 

Instead of

request.user.get_username

Leave a Reply