"""
WSGI config for homemanager project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os
from pathlib import Path
from homemanager.settings import DATABASES
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'homemanager.settings')

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

data = DATABASES["default"]["NAME"]
if not data.is_file():
    from django.core.management import call_command
    call_command("migrate", "--noinput")
    call_command("collectstatic", "--noinput")

    from django.contrib.auth import get_user_model
    User = get_user_model()
    User.objects.create_superuser('adp', 'a@a.com', 'password')
    User.objects.create_superuser('fabian', 'b@a.com', 'password')

