Skip to content

Instantly share code, notes, and snippets.

@richardARPANET
Created April 13, 2024 14:28
Show Gist options
  • Save richardARPANET/592d96c4c99a634fdc5bc1d3c52854fa to your computer and use it in GitHub Desktop.
Save richardARPANET/592d96c4c99a634fdc5bc1d3c52854fa to your computer and use it in GitHub Desktop.
apps.py
from django.apps import AppConfig
from django.contrib.auth.models import User
class MyAppConfig(AppConfig):
name = 'my_app'
def ready(self):
if not User.objects.filter(is_superuser=True, email='admin@example.com').exists():
User.objects.create_superuser(
username='admin',
email='admin@example.com',
password='adminpassword'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment