From d5988001a37315af33d84e286f05c55ee84197da Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 12 Dec 2023 18:04:30 +0000 Subject: [PATCH] Hide warnings --- yamdl_playground/core/apps.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yamdl_playground/core/apps.py b/yamdl_playground/core/apps.py index 86fea10..f3ee13c 100644 --- a/yamdl_playground/core/apps.py +++ b/yamdl_playground/core/apps.py @@ -1,6 +1,7 @@ from django.apps import AppConfig from django.db import connections from django.db.models.signals import post_save +import warnings class CoreConfig(AppConfig): name = "yamdl_playground.core" @@ -11,8 +12,11 @@ class CoreConfig(AppConfig): if not self.loaded: connection = connections["default"] - with connection.cursor() as cursor: - cursor.execute("CREATE VIRTUAL TABLE search_index USING fts5(body);") + with warnings.catch_warnings(): + # Django doesn't like running DB queries during app initialization + warnings.filterwarnings("ignore", module="django.db", category=RuntimeWarning) + with connection.cursor() as cursor: + cursor.execute("CREATE VIRTUAL TABLE search_index USING fts5(body);") post_save.connect(self.post_save) self.loaded = True