Skip to main content

🔐 Django Create Initial User

Effortless superuser creation for Django projects

Django Create Initial User Logo

🧪 Tests 📦 PyPI 🐍 Python 🎯 Django

📈 Coverage ⭐ Stars 📄 License 🔄 Downloads

Skip the hassle of python manage.py createsuperuser and jump straight into development!

🚀 Quick Start📖 Documentation🔧 Installation🤝 Contributing


🌟 Why Django Create Initial User?

😤 Before (The Old Way)

# 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

😎 After (The Django Create Initial User Way)

# 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!


✨ 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
  1. Start your Django project normally
  2. Navigate to /admin/
  3. Login with ANY credentials you want for your superuser
  4. ✨ 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

🏃‍♂️ Rapid Prototyping

Skip admin setup
Jump straight to coding
Perfect for hackathons

🐳 Docker Development

No interactive prompts
Automated container setup
DevOps engineers love this

🎓 Teaching Django

Students focus on concepts
Not admin user creation
Educators' favorite tool

🔄 CI/CD Pipelines

Automated testing
No manual intervention
QA teams rejoice


🛡️ 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_BACKENDS after 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

🏆 Quality Metrics

Coverage Security Code 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

Python 3.9 Python 3.10 Python 3.11 Python 3.12

🎯 Django Support

Django 3.2 Django 4.0 Django 4.1 Django 4.2 Django 5.0


🤝 Contributing

Love this project? Here's how you can help! 💖

🌟 Star the Repo

Show your support by
starring the repository!
It really motivates us!

Star

🐛 Report Issues

Found a bug?
Have a feature idea?
We want to hear from you!

Issues

🔀 Submit PRs

Code contributions
are always welcome!
Check our contributing guide

PRs

💻 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

Downloads Thank you for using our package!

🌟 Community

Contributors Amazing contributors making this better

🔄 Activity

Commits Actively maintained and improved


🎊 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.

License

© 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

🎉 Thank You for Using Django Create Initial User!

If this package helped you, please consider giving it a ⭐ star on GitHub!

Star History Chart


Made with ❤️ by developers, for developers

Happy coding! 🚀

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_create_initial_user-1.2.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_create_initial_user-1.2.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file django_create_initial_user-1.2.3.tar.gz.

File metadata

File hashes

Hashes for django_create_initial_user-1.2.3.tar.gz
Algorithm Hash digest
SHA256 1c3f66c2ef948b357218f69c70ed335ba730acc8169ccdd7bbd940af57f695a3
MD5 e84ca1c704bd7549b1b9e7c802a02744
BLAKE2b-256 06d492e30255df07417f4c534b6d3154afddfacdee37ca7baf75545b11c61809

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_create_initial_user-1.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_create_initial_user-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 87d3b97e01da4d14b349bd0312b3d456391e184a67f38b2d4ae7b8e41a71b61f
MD5 662a5ca3ffae840b1b0a2c28c0036ed0
BLAKE2b-256 8954d6488879d6f7c2aa42bb8383cc9ba671b48f2e49ba8cfcad7c9db433b217

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 files

1.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page