Skip to main content

Create a superuser if it doesn't exist, in the non interactive mode, using environment variables to set the email and password

Project description

Django Ensure Superuser

A simple Django management command to create a superuser non-interactively if one does not already exist.

This is useful for automating the setup of a Django application, for example, in a Docker container or a deployment script.

Installation

  1. Install the package using pip:
pip install django-ensuresuperuser
  1. Add django_ensuresuperuser to your INSTALLED_APPS setting in your Django project's settings.py:
INSTALLED_APPS = [
    # ...
    'django_ensuresuperuser',
]

Usage

Assuming all variables are set, run the management command:

python manage.py ensuresuperuser

Configuration

The command requires the following environment variables to be set:

  • DJANGO_SUPERUSER_PASSWORD: The password for the superuser.
  • DJANGO_SUPERUSER_EMAIL (optional): The email for the superuser. Defaults to admin@example.com.

The superuser will be created with the username admin. If a user with the username admin already exists, the command will do nothing.

Example

export DJANGO_SUPERUSER_PASSWORD="mysecretpassword"
export DJANGO_SUPERUSER_EMAIL="admin@mydomain.com"
python manage.py ensuresuperuser

Project details


Download files

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

Source Distribution

django_ensuresuperuser-0.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

django_ensuresuperuser-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file django_ensuresuperuser-0.1.1.tar.gz.

File metadata

  • Download URL: django_ensuresuperuser-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_ensuresuperuser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a8655ca8447cd674b32cfe6eb4ade339a8e480ee80a599ecb61592f02527b583
MD5 a50e213e792d90d618a02e5a92ad30cc
BLAKE2b-256 243d73344d7cda1839a6a817df3dfa63d65afcc9adc74990fd4a2deec27d7bbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ensuresuperuser-0.1.1.tar.gz:

Publisher: python-package.yml on ChrisW-priv/django_ensuresuperuser

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_ensuresuperuser-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ensuresuperuser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a2c8a821bdd45aabf782c92de2ece819eb574d22a04454bd357a996009b23fe
MD5 76d8992ba4e06892dd1763aa24384ebd
BLAKE2b-256 7d65d8204434b0fc43c3432638ea413b19c87c829e9124db54c8c8b2f0f7bb0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_ensuresuperuser-0.1.1-py3-none-any.whl:

Publisher: python-package.yml on ChrisW-priv/django_ensuresuperuser

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page