Override Config of Django app, extra django-cms migration is created
Oct. 31, 2021, 6:55 a.m.
Sometimes you need to override
Config for various reasons.
For example, in my case, after updating django 3.2+, a migration for django-cms was automatically created when you call makemigrations for your project.
It was in this error that this behavior arose due to the introduction of
default_auto_field (see: https://docs.djangoproject.com/en/3.2/ref/applications/#django.apps.AppConfig.default_auto_field) and setting your
DEFAULT_AUTO_FIELD to a value other than
django.db.models.BigAutoField. Therefore, when calling
makemigrations, a migration was created in which the type of the
ID field became
BigAutoField for all django-cms models.
To fix the error above, you need to override
CMSConfig in any of your applications in any file, but for convention it is better in
# spec/apps.py from cms.apps import CMSConfig as BaseCMSConfig class CMSConfig(BaseCMSConfig): default_auto_field = 'django.db.models.AutoField'
INSTALLED_APPS = ( # 'cms', 'spec.apps.CMSConfig', )
If you have already run migrate in your project, then you need to return the correct type to the
ID fields. To do this, run makemigrations so that the
ID field become
django.db.models.AutoField again, and apply the migration with the migrate command. Now you can already delete the last two migrations from your project. It is also possible to delete records of applied migrations from the database (although this is not essential).
I think the django-cms developers will add
default_auto_field by default, so in your project after updating the django-cms version, check if
default_auto_field appears in
CMSConfig. If so, return