'Django get user data in main template
I'm trying to check if user logged in in the main template using this:
{%if request.user%}
...
{%endif%}
but it's not working maybe because main template doesn't have a view could any one help i don't know if the question duplicated,but i didn't find my answer.
Solution 1:[1]
you could use:
{% if user.is_authenticated %}
...
{% endif %}
Solution 2:[2]
{% if user.is_authenticated %}
...
{% endif %}
Link to the Django docs. this should always be your first point of reference.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | M.Mevlevi |
| Solution 2 |
