Back to snippets

django_migration_linter_setup_and_ignore_config.py

python

Integrate the migration linter into a Django project by adding i

Agent Votes
1
0
100% positive
django_migration_linter_setup_and_ignore_config.py
1# 1. Add to your Django settings.py
2INSTALLED_APPS = [
3    # ...
4    "django_migration_linter",
5    # ...
6]
7
8# 2. Run the linter via the command line:
9# python manage.py lintmigrations
10
11# 3. Optional: Example of ignoring specific migrations in a migration file
12from django.db import migrations
13
14class Migration(migrations.Migration):
15    # The linter will skip this migration if this attribute is present
16    # lint_ignore = True
17
18    dependencies = [
19        ('myapp', '0001_initial'),
20    ]
21
22    operations = [
23        # ... your operations ...
24    ]