This project gives you a middleware that allow you to login to any user via django command.
- Install
pip install django-dev-admin
- Add
django_dev_admin
to yourINSTALLED_APPS
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
...,
"django_dev_admin",
]
- Add
django_dev_admin.middleware.DevAdminMiddleware
to yourMIDDLEWARE
afterdjango.contrib.sessions.middleware.SessionMiddleware
MIDDLEWARE = [
...,
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django_dev_admin.middleware.DevAdminMiddleware",
...,
]
If you are not using default development hostname and port. Please put this option in your settings.py
DEFAULT_DEV_SERVER = "http://localhost:8000"
python manage.py login_as
python manage.py login_as -u <username>
Please disable this module in production