from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Group # Откючаем тестовых пользователей (если такие есть), если DEBUG=False и наоброт try: if Group.objects.filter(name="TEST").exists(): test_group = Group.objects.get(name="TEST") users_in_test_group = get_user_model().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")