Allow visitors to interact with your site like a temporary user ("guest") without requiring registration.
Anonymous visitors who request a decorated page get a real temporary user object assigned and are logged in automatically. They can use the site like a normal user until they decide to convert to a real user account to save their data.
Inspired by and as an alternative for django-lazysignup and rewritten for modern Django and Python versions.
📋 Note: This repository (
django-guest-user2
) is a maintained fork of julianwachholz/django-guest-user, which appears to be unmaintained. This fork includes bug fixes, dependency updates, expanded Django/Python version support, and ongoing maintenance. The "2" suffix distinguishes this maintained version from the original.
- 🚀 Zero-friction onboarding: Visitors can start using your app immediately
- 🔄 Seamless conversion: Easy upgrade from guest to registered user
- 🧹 Automatic cleanup: Built-in management commands for guest user cleanup
- 🛡️ Production ready: Comprehensive test suite across Python/Django versions
- 📚 Well documented: Complete documentation and examples
- 🎯 Modern codebase: Built for current Django and Python versions
- Python: 3.8, 3.9, 3.10, 3.11, 3.12
- Django: 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2
Tested across 27 different combinations to ensure compatibility and reliability.
Install from PyPI:
pip install django-guest-user
Note: The PyPI package name remains
django-guest-user
for compatibility, but the maintained source is now atrsp2k/django-guest-user2
.
-
Add to your Django project:
# settings.py INSTALLED_APPS = [ # ... your other apps 'guest_user', ] AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', 'guest_user.backends.GuestBackend', ]
-
Include URLs:
# urls.py from django.urls import path, include urlpatterns = [ # ... your other URLs path('guest/', include('guest_user.urls')), ]
-
Run migrations:
python manage.py migrate
-
Decorate your views:
from django.shortcuts import render from guest_user.decorators import allow_guest_user @allow_guest_user def my_view(request): # request.user is now always authenticated # (either a real user or a temporary guest) assert request.user.is_authenticated return render(request, "my_view.html")
That's it! Your visitors can now interact with your app without registration.
from django.shortcuts import render
from guest_user.decorators import allow_guest_user
from guest_user.functions import is_guest_user
@allow_guest_user
def shopping_cart(request):
if is_guest_user(request.user):
# Show conversion prompt for guest users
show_signup_prompt = True
else:
show_signup_prompt = False
return render(request, 'cart.html', {
'show_signup_prompt': show_signup_prompt,
})
Find the complete documentation on Read the Docs, including:
- Installation guide: Detailed setup instructions
- Configuration options: Customize guest user behavior
- Template tags: Helper functions for your templates
- Management commands: Cleanup and maintenance tools
- Advanced usage: Custom name generators, swappable models, and more
This project maintains high code quality standards:
- ✅ Comprehensive testing: 27 Python/Django version combinations
- ✅ Code formatting: Enforced with Black
- ✅ Linting: Flake8 with strict rules
- ✅ Type hints: Full type annotation coverage
- ✅ Documentation: Complete API documentation and examples
All contributions are welcome! Here's how to get started:
- Fork the repository
- Set up development environment:
git clone https://github.com/your-username/django-guest-user2.git cd django-guest-user2 pip install poetry poetry install
- Run tests:
poetry run pytest # Or test all environments: poetry run tox
- Follow code standards:
poetry run black . poetry run flake8
Please read our contributing guidelines for more details.
If you're migrating from django-lazysignup
, check our migration guide for step-by-step instructions.
This project is under active development with regular updates and improvements.
This repository (django-guest-user2
) is a maintained fork of the original julianwachholz/django-guest-user project, which appears to be abandoned (last updated in early 2023). This fork provides:
- ✨ Bug fixes and improvements
- 🔄 Dependency updates (including Django 5.x support)
- 🧪 Expanded testing across more Python/Django combinations
- 📚 Updated documentation
- 🛠️ Ongoing maintenance and issue resolution
The core functionality is stable and production-ready, built upon the solid foundation of both django-lazysignup and the original django-guest-user.
Recent improvements in this fork:
- ✨ Enhanced request parameter support in name generators
- 🔧 Improved dependency management and testing
- 📚 Updated documentation for Django 5.x
- 🛡️ Expanded test matrix for better compatibility
- 🐛 Fixed missing dependency issues
This project is licensed under the MIT License - see the LICENSE file for details.
- Original django-lazysignup project by Dan Fairs
- Original django-guest-user project by Julian Wachholz
- All the contributors who have helped improve this package