diff --git a/app/app/cli.py b/app/app/cli.py index ad32396..f7ba95d 100644 --- a/app/app/cli.py +++ b/app/app/cli.py @@ -12,6 +12,8 @@ def main(): """CLI entry point for running the development server.""" try: from django.core.management import execute_from_command_line + from django.db import connections + from django.apps import apps except ImportError as exc: raise ImportError( "Couldn't import Django. Make sure it's installed and " @@ -28,6 +30,9 @@ def main(): if len(sys.argv) > 2: os.environ["LAB_CONTENT_ENTRYPOINT"] = sys.argv[2] execute_from_command_line(["manage.py", "migrate"]) + for conn in connections.all(): + conn.close() + apps.clear_cache() execute_from_command_line(["manage.py", "runserver"]) else: print(f"Unknown command: {sys.argv[1]}")