The solution I can think of is to subclass the Django makemigrations to set a flag before actually executing the actual operation.
Example:
Put this code in <someapp>/management/commands/makemigrations.py , it will override the default makemigrations Django makemigrations .
from django.core.management.commands import makemigrations from django.db import migrations class Command(makemigrations.Command): def handle(self, *args, **kwargs):
Do the same for the migrate command.
And change the dynamic selection function:
from django.db import migrations def lazy_discover_foreign_id_choices(): if getattr(migrations, 'MIGRATION_OPERATION_IN_PROGRESS', False): return []
These are very hacks, but quite easy to configure.
source share