Dependencies
This project is thoroughly tested on these setups:
Python 3.8, 3.9, 3.10, 3.11 and 3.12
Django 3.2, 4.0, 4.1, 4.2 and the main branch
In addition, your Django project should be using django.contrib.auth.
How to install
Install the package from PyPI with your favorite package manager:
pip install django-guest-user
# or simiar, e.g.
poetry add django-guest-user
Add the app to your django:ref/settings:``installed_apps`` and django:ref/settings:``authentication_backends``:
# settings.py
INSTALLED_APPS = [
# ... other apps
"guest_user",
]
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
# it should be the last entry to prevent unauthorized access
"guest_user.backends.GuestBackend",
]
Allow guests to convert to registered users by adding the URLs to your URLconf:
# urls.py
urlpatterns = [
# ... other patterns
path("convert/", include("guest_user.urls")),
]
Last but not least, prepare the guest user table by running migrations:
python manage.py migrate
Migrating from django-lazysignup
django-guest-user
can be used a a drop-in replacement for django-lazysignup.
Given the temporary nature of guest or lazy users, the packages can be replaced without breaking the functionality of any existing (non-temporary) users.
Note
By uninstalling lazysignup, any current temporary users will lose their associated data and be signed out of their session.
The following decorators and template filters need to be replaced by their respective counterparts.
@allow_lazy_user
➡️@allow_guest_user
@require_lazy_user
➡️@guest_user_required
@require_nonlazy_user
➡️@regular_user_required
Template filter
is_lazy_user
➡️is_guest_user