🔐 Django Create Initial User
Effortless superuser creation for Django projects
Skip the hassle of python manage.py createsuperuser and jump straight into development!
🚀 Quick Start • 📖 Documentation • 🔧 Installation • 🤝 Contributing
🌟 Why Django Create Initial User?
✨ Features That Make You Go "Wow!"
| 🎯 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 |
🚀 Quick Start
📦 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! 🎊
🎬 See It In Action
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!
📊 Comparison Matrix
| 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 | ✅ | ❌ | ✅ |
🎯 Perfect For
🛡️ Security Features
# 🔒 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_BACKENDSafter creating your production superuser.
📚 Documentation
| 📖 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 |
🎨 Advanced Usage
🔧 Custom Configuration Examples
Production-Ready Setup
# 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 Integration
# docker-compose.yml
services:
web:
build: .
environment:
- DEBUG=True
- ENABLE_INITIAL_SUPERUSER=1
ports:
- "8000:8000"
Custom User Model Support
# 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! 🎉
🧪 Testing & Quality
# 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
📊 Test Coverage
- ✅ 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
🚀 Performance & Compatibility
🐍 Python Support
🎯 Django Support
🤝 Contributing
Love this project? Here's how you can help! 💖
💻 Development Setup
# 🚀 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! 🎉
🏆 Recognition & Stats
📈 Downloads
|
🌟 Community
|
🔄 Activity
|
🎊 Success Stories
"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
📄 License & Legal
This project is licensed under the MIT License - see the LICENSE file for details.
© 2025 Django Create Initial User Contributors
🔗 Links & Resources
| 🌐 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 |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_create_initial_user-1.2.3.tar.gz.
File metadata
- Download URL: django_create_initial_user-1.2.3.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c3f66c2ef948b357218f69c70ed335ba730acc8169ccdd7bbd940af57f695a3
|
|
| MD5 |
e84ca1c704bd7549b1b9e7c802a02744
|
|
| BLAKE2b-256 |
06d492e30255df07417f4c534b6d3154afddfacdee37ca7baf75545b11c61809
|
Provenance
The following attestation bundles were made for django_create_initial_user-1.2.3.tar.gz:
Publisher:
publish.yml on rsp2k/django-create-initial-user
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_create_initial_user-1.2.3.tar.gz -
Subject digest:
1c3f66c2ef948b357218f69c70ed335ba730acc8169ccdd7bbd940af57f695a3 - Sigstore transparency entry: 232943136
- Sigstore integration time:
-
Permalink:
rsp2k/django-create-initial-user@b4ddfad25a91bf7e4f197e7c6ce00e05398dcf2e -
Branch / Tag:
refs/tags/v1.2.3 - Owner: https://github.com/rsp2k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4ddfad25a91bf7e4f197e7c6ce00e05398dcf2e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_create_initial_user-1.2.3-py3-none-any.whl.
File metadata
- Download URL: django_create_initial_user-1.2.3-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d3b97e01da4d14b349bd0312b3d456391e184a67f38b2d4ae7b8e41a71b61f
|
|
| MD5 |
662a5ca3ffae840b1b0a2c28c0036ed0
|
|
| BLAKE2b-256 |
8954d6488879d6f7c2aa42bb8383cc9ba671b48f2e49ba8cfcad7c9db433b217
|
Provenance
The following attestation bundles were made for django_create_initial_user-1.2.3-py3-none-any.whl:
Publisher:
publish.yml on rsp2k/django-create-initial-user
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_create_initial_user-1.2.3-py3-none-any.whl -
Subject digest:
87d3b97e01da4d14b349bd0312b3d456391e184a67f38b2d4ae7b8e41a71b61f - Sigstore transparency entry: 232943143
- Sigstore integration time:
-
Permalink:
rsp2k/django-create-initial-user@b4ddfad25a91bf7e4f197e7c6ce00e05398dcf2e -
Branch / Tag:
refs/tags/v1.2.3 - Owner: https://github.com/rsp2k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4ddfad25a91bf7e4f197e7c6ce00e05398dcf2e -
Trigger Event:
workflow_dispatch
-
Statement type: