How to fix/ignore pending migration in 3rd-party app?

After updating to Django 4.0, the migration autodetector is picking up changes in a third-party app I have installed. Because I use ./ makemigrations --check in my CI this is currently preventing me from deploying the update.

Is there a workaround (even an ugly hack) I could use to tell makemigrations to ignore a specific app?
I’ve tried using MIGRATION_MODULES = {'the_app': None} in my settings but then Django complains because some of my other apps have migrations that depend on the 3rd-party app.

Are these changes by any chance related to the default primary key being changed from int to big int? If so, there is a work-around for that by creating an AppConfig for the third-party app and setting the default_auto_field.

Beyond that, you can specify the apps for makemigrations to check, but not an option to ignore. You could list all your apps you want checked on the makemigrations command.

I’m pretty sure the changes are caused by this: Django 4.0 release notes | Django documentation | Django

I’ve been trying to hack some kind of module wrapper using __getattr__ (pep 562) to inject the missing migration myself but I can’t get it to do what I want.

Listing all the apps explicitly seems to work. I thought maybe the dependency would get “pulled in” but that doesn’t appear to be the case.
But my project has ~50 apps in INSTALLED_APPS so that’s not a very practical solution (not to mention the fact that I’d have to keep the list in sync somehow).

I’m curious, what package is affected by this and what is the migration being generated?

You could write your own “makemigrations” command that wrappers around the system command. It could interrogate your application and build the appropriate command for the system function.

The app in question is django-taggit: AUto-generated migration with Django 4.0 · Issue #784 · jazzband/django-taggit · GitHub

I’ve opened a PR with but I’m looking for a temporary solution that’s not too disruptive and also easy to remove once the fix arrives upstream.

Wrapping makemigrations in a custom command is a good idea, I’ll give it a go.


The custom command was fairly straightforward to implement, here’s what I ended up with:

from django.apps import apps
from import Command as OriginalCommand


class Command(OriginalCommand):
    def handle(self, *app_labels, **options):
        if app_labels or not options['check_changes']:
            return super().handle(*app_labels, **options)

        app_labels = {cfg.label for cfg in apps.get_app_configs()} - IGNORED_MISSING_MIGRATIONS
        return super().handle(*app_labels, **options)

I’ve put that in a dedicated app which I can simply delete once the fix is released upstream.

Thanks again for the suggestion!


That is so cool! That’s a lot nicer solution than I would have thought of. Thanks for sharing.

1 Like

That is a good workaround :+1: