[Answered ]-Guest Checkout in django

1👍

The easiest way it would be to set request.session['user'] to some default value (e.g. guest) by default (you can do

try:
    request.session['user']
except KeyError:
    request.session['user'] = 'guest'

at the start of every view function (pr functions that can be accessible directly by typing some URL. That’s what I’ve always done and it makes miracles ;). What it actually does is checks whether a user is logged in (request.session has the key user) or not (request.session does not have the key user). When user logs in, set request.session['user'] to his username.

1👍

You don’t want to touch the django_session table yourself.

Instead, please read

The gist of it is that you can store things in the session dict using

request.session['foo'] = True

and they will be transparently persisted using a cookie. You can retrieve them similarly.

👤AKX

    Leave a comment