This is a third-party package built for testing how an experimental framework would work in Django.
The goal of this project is to create a safe playground where new features can be built and tested using feature flags, without risking the stability of the main Django framework.
pip install django-experimental
The setup uses dynamic injection at compilation time. This approach keeps settings.py clean by automatically adding required
apps and experiment specific settings and prevents ghost logs when an experiment is turned off.
- Add django.experimental to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django.experimental",
]- Add the experimental flags dictionary and the registration hook at the bottom of your
settings.py:
# At the bottom of settings.py
DJANGO_EXPERIMENTAL_FLAGS = {
"ENABLE_NEWAUTH": True,
}
from django.experimental import register_experimental_features
register_experimental_features(globals())When ENABLE_NEWAUTH is set to True, the registration engine automatically:
- Adds
django.experimental.contrib.authintoINSTALLED_APPS. - Sets
AUTH_USER_MODEL = "experimental_auth.User"(unless a custom user model is already configured). - Adds
django.experimental.contrib.auth.backends.DualAuthenticationBackendtoAUTHENTICATION_BACKENDS.
When ENABLE_NEWAUTH is set to False, nothing is added and hence no ghost logs.
If you prefer to configure all settings explicitly without dynamic injection:
Add both the root package and the experimental module to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django.experimental",
"django.experimental.contrib.auth",
]Configure the user model, authentication backends, and experimental flags in settings.py:
AUTH_USER_MODEL = "experimental_auth.User"
AUTHENTICATION_BACKENDS = [
# ...
"django.experimental.contrib.auth.backends.DualAuthenticationBackend",
"django.contrib.auth.backends.ModelBackend",
]
DJANGO_EXPERIMENTAL_FLAGS = {
"ENABLE_NEWAUTH": True,
}NEWAUTH: An updated User model for Django that includes a single full name field (replacing first/last name),
unique email addresses, and supports logging in with a username or email.