In yourApp
/management/commands
create ready_site.py
:
from django.contrib import auth
from django.core.management.base import BaseCommand, CommandParser
from django.apps import apps
class Command(BaseCommand):
help= 'Ready the site for openning'
def add_arguments(self, parser: CommandParser) -> None:
pass
def handle(self, *args, **options):
for app in apps.get_app_configs():
if hasattr(app, 'ready_site'):
app.ready_site()
Create a blank __init__.py
in yourApp
/management
and yourApp
/management/commands
.