How do I check whether this user is anonymous or actually a user on my system?

后端 未结 4 907
粉色の甜心
粉色の甜心 2020-12-24 00:24
def index(request):
    the_user = request.user

In Django, how do I know if it\'s a real user or not? I tried:

if the_user:

4条回答
  •  难免孤独
    2020-12-24 00:36

    I had a similar issue except this was on a page that the login_redirect_url was sent to. I had to put in the template:

    {% if user.is_authenticated %}
        Welcome Back, {{ username }}
    {% endif %}
    

提交回复
热议问题