"""Manage.py with auto migrate for runserver., also usable as entry_point"""

#!/usr/bin/env python
import os
import sys

def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "YOUR_PROJECT.settings")
    from django.core.management import call_command, execute_from_command_line
    if sys.argv[1] == 'runserver':
        import django
        django.setup()
        call_command('migrate')

        from django.conf import settings
        from django.apps import apps
        User = apps.get_model(settings.AUTH_USER_MODEL)
        if not User.objects.count():
            call_command('createsuperuser')

    execute_from_command_line(sys.argv)

if __name__ == "__main__":
    main()