2👍
✅
Lets say you have a list called ‘user_list’
def logout_view(logout):
# Do whatever pre conditions you have here.
my_list = request.session['user_list']
logout(request)
# Now Django would have flushed your previous sessions and created a new session.
request.session['user_list'] = my_list
return HttpResponse() # Or render to response i.e whatever you do.
Now make sure that a session is being created for anonymous user also. And rest everything will work. Hope it does for you.
Source:stackexchange.com