Skip to content

Commit

Permalink
runserver_quit manage.py command to ignore migration warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Jan 4, 2025
1 parent edf7c31 commit 5eca8cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/app/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def main():
sys.path.insert(0, str(BASE_DIR))
if len(sys.argv) > 2:
os.environ["LAB_CONTENT_ENTRYPOINT"] = sys.argv[2]
execute_from_command_line(["manage.py", "runserver_migrate"])
execute_from_command_line(["manage.py", "collectstatic", "--noinput"])
execute_from_command_line(["manage.py", "runserver_quiet"])
else:
print(f"Unknown command: {sys.argv[1]}")

Expand Down
2 changes: 1 addition & 1 deletion app/app/settings/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': ':memory:',
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from django.core.management.commands.runserver import (
Command as RunserverCommand,
)
Expand All @@ -6,8 +7,9 @@

class Command(RunserverCommand):
def handle(self, *args, **options):
self.stdout.write("Applying migrations...")
call_command("migrate")
self.stdout.write("Migrations applied successfully.")
warnings.filterwarnings(
"ignore",
message="apply the migration",
)
call_command("collectstatic", "--noinput")
super().handle(*args, **options)

0 comments on commit 5eca8cd

Please sign in to comment.