Metadata-Version: 2.1
Name: django-createsuperuser-signal
Version: 0.0.1
Summary: Django app to create superuser from environment after migrations
Home-page: https://github.com/BabisK/django-createsuperuser
Author: Babis Kaidos
Author-email: ckaidos@intracom-telecom.com
License: Apache Software License
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django :: 1.8
Classifier: Framework :: Django :: 1.9
Classifier: Framework :: Django :: 1.10
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
Description-Content-Type: text/markdown
License-File: LICENSE

# django-createsuperuser
Django app that implements a signal to create super user from environment
variables on migration. Useful for Docker, Kubernetes etc. If the user already
exists it will do nothing.

## Installation

Simply download from Pypi:
```bash
pip install django_superuser
```

## Usage

This app needs to register in the `INSTALLED_APPS` list in your Django settings:

```python
INSTALLED_APPS = [
    ...
    "createsuperuser",
    ...
]
```

As it is, it will do nothing. You need to define 4 environment variables through
which the superuser will be created during the migration stage (uses the
post_migrate signal).

| Environment Variable | Description |
| -------------------- | ----------- |
| DJANGO_SUPERUSER_CREATE | Enables the process of creating the superuser. Must be true or false (case insensitive) |
| DJANGO_SUPERUSER_USERNAME | The username of the superuser account to create |
| DJANGO_SUPERUSER_EMAIL | The email of the superuser account |
| DJANGO_SUPERUSER_PASSWORD | The password of the superuser account |

After defining these variables, the superuser will be created the next time you
perform a migration (even if no migrations are applied)

```bash
export DJANGO_SUPERUSER_CREATE=true
export DJANGO_SUPERUSER_USERNAME=admin
export DJANGO_SUPERUSER_EMAIL=admin@example.com
export DJANGO_SUPERUSER_PASSWORD=admin
python manage.py migrate
```

You can use this to create the user when launching your django project in Docker
by passing the variables in the command. Or if you are using Kuberenetes you can
add them in a `Secret` and pass them in the pod via `envFrom`. Or however the
environment variables fit in your workflow.

