ソースを参照

Fixed a bug where model checks could occur before models were created

TonyKurts 3 ヶ月 前
コミット
3f12d7f0cc
1 ファイル変更9 行追加6 行削除
  1. 9 6
      sharix_admin/signals.py

+ 9 - 6
sharix_admin/signals.py

@@ -127,9 +127,12 @@ def create_initial_ticket_lists(sender, **kwargs):
 
 
 # Откючаем тестовых пользователей (если такие есть), если DEBUG=False и наоброт
-if Group.objects.filter(name="TEST").exists():
-    test_group = Group.objects.get(name="TEST")
-    users_in_test_group = User.objects.filter(groups=test_group)
-
-    if users_in_test_group:
-        users_in_test_group.update(is_active=settings.DEBUG)
+try:
+    if Group.objects.filter(name="TEST").exists():
+        test_group = Group.objects.get(name="TEST")
+        users_in_test_group = User.objects.filter(groups=test_group)
+
+        if users_in_test_group:
+            users_in_test_group.update(is_active=settings.DEBUG)
+except:
+    print("Test user validation is not available. Models have not been created yet")