-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapps.py
More file actions
26 lines (18 loc) · 747 Bytes
/
apps.py
File metadata and controls
26 lines (18 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import annotations
import os
import logging
from django.apps import AppConfig
from django.core import management
from root.constants import Environment
LOG = logging.getLogger('samfundet')
class SamfundetConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'samfundet'
def ready(self) -> None:
from . import signals # noqa: F401 # Important, this enables signals.
if os.environ['ENV'] == Environment.DEV:
try:
LOG.info(f"Attempt to create superuser '{os.environ.get('DJANGO_SUPERUSER_USERNAME')}'")
management.call_command('createsuperuser', interactive=False)
except Exception as e:
LOG.info(e)