django message when logout

前端 未结 5 2021
青春惊慌失措
青春惊慌失措 2020-12-18 04:24

Once an user logged out of the site, it should redirect to the home page and to display the message as \"U are successfully logged out\" in the top of the page. Anyone help

5条回答
  •  情歌与酒
    2020-12-18 04:36

    Try using sessions. Can be simpler.

    In the logout view, set an entry in the session variable, like session['just_logged_out'] = True, and in the home page view, check for the variable.

    try:
      just_logged_out = request.session.get('just_logged_out',False)
    except:
      just_logged_out = False
    

    In the template, you can use

    {% if just_logged_out %}  You are successfully logged out {% endif %}
    

提交回复
热议问题