I have created a series of checks using Django's System check framework.
Some of the checks are used to confirm that fixtures are set up correctly. For example, I have a check that confirms if all users have at least one group.
@register(Tag.database)
def check_users_have_group(app_configs, **kwargs):
errors = []
users = UserModel.objects.all()
for user in users:
if not user.groups.exists():
message = f'{user} has no permission groups set.'
errors.append(
Error(
message,
obj='account',
id=f'check_user_{user.id}_permission_groups'
)
)
return errors
Django's default is to run checks on migration
. If I deploy the app without an existing database, then when I run migrate
to set up the database the above check will cause a ProgrammingError
because the table is not yet created:
django.db.utils.ProgrammingError: relation "accounts_account" does not exist
How can I exclude this test from running on python manage.py migrate
? I want to run this after the migration is complete.