1
Fork 0

Hide warnings

This commit is contained in:
Jake Howard 2023-12-12 18:04:30 +00:00
parent aab93a4d3e
commit d5988001a3
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,6 +1,7 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.db import connections from django.db import connections
from django.db.models.signals import post_save from django.db.models.signals import post_save
import warnings
class CoreConfig(AppConfig): class CoreConfig(AppConfig):
name = "yamdl_playground.core" name = "yamdl_playground.core"
@ -11,8 +12,11 @@ class CoreConfig(AppConfig):
if not self.loaded: if not self.loaded:
connection = connections["default"] connection = connections["default"]
with connection.cursor() as cursor: with warnings.catch_warnings():
cursor.execute("CREATE VIRTUAL TABLE search_index USING fts5(body);") # 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) post_save.connect(self.post_save)
self.loaded = True self.loaded = True