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

Metadata

Release files for django-create-initial-user 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-create-initial-user 1.2.3
File Size Uploaded Provenance
django_create_initial_user-1.2.3.tar.gz 15.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-create-initial-user 1.2.3
File Interpreter ABI Platform
django_create_initial_user-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / django_create_initial_user-1.2.3.tar.gz

Download URL django_create_initial_user-1.2.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c3f66c2ef948b357218f69c70ed335ba730acc8169ccdd7bbd940af57f695a3
BLAKE2b-256 checksum
How to use checksums
06d492e30255df07417f4c534b6d3154afddfacdee37ca7baf75545b11c61809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.

Transparency log

Release files / django_create_initial_user-1.2.3-py3-none-any.whl

Download URL django_create_initial_user-1.2.3-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87d3b97e01da4d14b349bd0312b3d456391e184a67f38b2d4ae7b8e41a71b61f
BLAKE2b-256 checksum
How to use checksums
8954d6488879d6f7c2aa42bb8383cc9ba671b48f2e49ba8cfcad7c9db433b217
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.

Transparency log

Security for django-create-initial-user 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_create_initial_user-1.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files Full provenance

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