diff --git a/djangocms_blog/migrations/0044_copy_plugins.py b/djangocms_blog/migrations/0044_copy_plugins.py index a5a89f03..c20ef447 100644 --- a/djangocms_blog/migrations/0044_copy_plugins.py +++ b/djangocms_blog/migrations/0044_copy_plugins.py @@ -2,8 +2,6 @@ from django.contrib.auth import get_user_model from django.db import migrations, models -User = get_user_model() - class BareVersion: """Patches the save method of a model to standard model save.""" @@ -23,6 +21,12 @@ def move_plugins_to_blog_content(apps, schema_editor): """Adds instances for the new model. ATTENTION: All fields of the model must have a valid default value!""" + User = apps.get_model(*settings.AUTH_USER_MODEL.split(".")) + Post = apps.get_model("djangocms_blog", "Post") + PostContent = apps.get_model("djangocms_blog", "PostContent") + ContentType = apps.get_model("contenttypes", "ContentType") + content_type, _ = ContentType.objects.get_or_create(app_label="djangocms_blog", model="postcontent") + versioning_installed = apps.is_installed("djangocms_versioning") if versioning_installed: if getattr(settings, "CMS_MIGRATION_USER_ID", None): @@ -32,11 +36,6 @@ def move_plugins_to_blog_content(apps, schema_editor): else: migration_user = None - Post = apps.get_model("djangocms_blog", "Post") - PostContent = apps.get_model("djangocms_blog", "PostContent") - ContentType = apps.get_model("contenttypes", "ContentType") - content_type, _ = ContentType.objects.get_or_create(app_label="djangocms_blog", model="postcontent") - for post in Post.objects.all(): if not post.postcontent_set.exists(): # Not yet migrated