Skip the hassle of python manage.py createsuperuser
and jump straight into development!
π Quick Start β’ π Documentation β’ π§ Installation β’ π€ Contributing
# Every. Single. Time.
python manage.py migrate
python manage.py createsuperuser
# Enter username: admin
# Enter email: admin@example.com
# Enter password: ********
# Enter password (again): ******** Result: Repetitive setup, broken automation, frustrated developers |
# settings.py - One time setup
if DEBUG:
AUTHENTICATION_BACKENDS.insert(0,
'create_initial_superuser.backends.CreateInitialSuperUserBackend'
) Result: π― Login with ANY credentials β β¨ Instant superuser β π Start coding! |
π― Smart Creation | π‘οΈ Security First | π§ Zero Config | π§ͺ Battle Tested |
---|---|---|---|
Only creates superuser when none exist | DEBUG-mode only by default | Works out of the box | 100% test coverage |
Auto-detects email usernames | Proper password hashing | No database changes | Supports Django 3.2-5.0 |
Transparent warning system | Production-safe defaults | Type-hinted codebase | Python 3.9-3.12 ready |
π¦ Installation
# Using pip
pip install django-create-initial-user
# Using uv (recommended)
uv add django-create-initial-user
# Using poetry
poetry add django-create-initial-user
βοΈ Configuration
Add to your Django settings.py
:
# Add to INSTALLED_APPS
INSTALLED_APPS = [
# ... your apps
'create_initial_superuser',
]
# Configure authentication backend
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]
# π₯ The magic happens here!
if DEBUG:
AUTHENTICATION_BACKENDS.insert(0,
'create_initial_superuser.backends.CreateInitialSuperUserBackend'
)
π Usage
- Start your Django project normally
- Navigate to
/admin/
- Login with ANY credentials you want for your superuser
- β¨ BOOM! You're now logged in as a superuser!
# That's literally it. No manage.py commands needed! π
sequenceDiagram
participant Dev as π¨βπ» Developer
participant Django as π― Django App
participant Backend as π Auth Backend
participant DB as ποΈ Database
Dev->>Django: Navigate to /admin/
Django->>Dev: Show login form
Dev->>Django: Submit credentials (admin/secret123)
Django->>Backend: authenticate(admin, secret123)
Backend->>DB: Check for superusers
DB->>Backend: No superusers found!
Backend->>DB: Create superuser(admin, secret123)
DB->>Backend: β
Superuser created
Backend->>Django: Return authenticated user
Django->>Dev: π Welcome to Django Admin!
The entire flow happens transparently - no manual steps required!
Feature | Manual createsuperuser | Fixtures | Django Create Initial User |
---|---|---|---|
π Zero Setup Time | β | β | |
π Works Every Time | β | β | |
π‘οΈ Production Safe | β | β | |
π― Custom Credentials | β | β | β |
π§ Smart Email Detection | β | β | |
π§ͺ Test Friendly | β | β | β |
π§ No Database Changes | β | β | β |
Skip admin setup |
No interactive prompts |
Students focus on concepts |
Automated testing |
# π Built-in Security Measures
β
DEBUG mode only by default
β
Proper password hashing (Django's make_password)
β
Transparent operation (warning messages)
β
No backdoors or hardcoded credentials
β
Production deployment warnings
β
Comprehensive security documentation
π¨ Security Note: This package is designed for development environments. While it can be used in production for initial deployment, we recommend removing it from
AUTHENTICATION_BACKENDS
after creating your production superuser.
π Guide | π Link | π Description |
---|---|---|
π Quick Start | Getting Started | Get up and running in 2 minutes |
βοΈ Configuration | Settings Guide | Advanced configuration options |
π‘οΈ Security | Security Guide | Best practices and considerations |
π API Reference | API Docs | Complete API documentation |
π Troubleshooting | FAQ | Common issues and solutions |
π€ Contributing | Contributing Guide | Help make this package better |
π§ Custom Configuration Examples
# settings.py
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]
# Only enable in development
if DEBUG or os.getenv('ENABLE_INITIAL_SUPERUSER'):
AUTHENTICATION_BACKENDS.insert(0,
'create_initial_superuser.backends.CreateInitialSuperUserBackend'
)
# docker-compose.yml
services:
web:
build: .
environment:
- DEBUG=True
- ENABLE_INITIAL_SUPERUSER=1
ports:
- "8000:8000"
# models.py
from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser):
email = models.EmailField(unique=True)
# The backend automatically works with any user model! π
# Run the comprehensive test suite
git clone https://github.com/rsp2k/django-create-initial-user.git
cd django-create-initial-user
# Quick test (using our dev script)
python dev-test.py
# Full test matrix (all Python/Django versions)
tox
# Security scan
make security
- β 100% line coverage across all modules
- β Edge case testing (missing credentials, DEBUG=False, etc.)
- β Security validation (password hashing, warning messages)
- β Integration testing with Django's auth system
- β Multi-version compatibility testing
Love this project? Here's how you can help! π
Show your support by |
Found a bug? |
Code contributions |
# π Quick development setup
git clone https://github.com/rsp2k/django-create-initial-user.git
cd django-create-initial-user
# Option 1: Automated setup (recommended)
make dev-setup
# Option 2: Manual setup with uv
uv venv # Creates .venv virtual environment
uv pip install -e ".[dev]" # Install with dev dependencies
uv run pre-commit install # Install git hooks
# Option 3: Complete pre-commit setup with validation
python setup-precommit.py # Interactive setup and validation
# Run tests and quality checks
make test # Or: python dev-test.py
make lint # Or: uv run pytest tests/
# You're ready to contribute! π
"This package saved me hours of setup time during a 48-hour hackathon. Absolute game-changer!"
β Sarah Chen, Full-Stack Developer
"We use this in all our Django training courses. Students can focus on learning Django instead of admin setup."
β Dr. Rodriguez, Computer Science Professor
"Perfect for our Docker-based CI/CD pipeline. No more interactive superuser creation breaking our builds!"
β Mike Thompson, DevOps Engineer
This project is licensed under the MIT License - see the LICENSE file for details.
Β© 2025 Django Create Initial User Contributors
π Resource | π Link |
---|---|
π¦ PyPI Package | pypi.org/project/django-create-initial-user |
π Documentation | docs.django-create-initial-user.com |
π Issue Tracker | GitHub Issues |
π¬ Discussions | GitHub Discussions |
π§ Email Support | support@django-create-initial-user.com |