Skip to content

Models defined in migration 0003 should define a dummy app_label #112

@jasperbok

Description

@jasperbok

We have a Django test that checks for pending migrations. Our CI runs python manage.py test, which runs this test. The test always fails, because Django tries to create a new migration to add the models CKEditorText and Text_Text, both defined in migration 0003_auto_20240702_1409.py.

When I run makemigrations, these models are not detected, as they're not present in a models.py. During testing, however, they seem to be detected. I don't understand exactly how or why.

The problem can be solved by adding a dummy app_label to the Meta classes of these models. When I make the following change in my local copy of the migration, the test passes.

class CKEditorText(models.Model):
        class Meta:
            managed = False
            db_table = "djangocms_text_ckeditor_text"
+           app_label = "not_actually_djangocms_text"

        cmsplugin_ptr_id = models.PositiveIntegerField(primary_key=True)
        body = models.TextField()

    class Text_Text(models.Model):  # Name must not be used elsewhere as model
        class Meta:
            managed = False
            db_table = "djangocms_text_text"
+           app_label = "not_actually_djangocms_text"

        cmsplugin_ptr_id = models.PositiveIntegerField(primary_key=True)
        body = models.TextField()
        json = models.JSONField(blank=True, null=True)
        rte = models.CharField(max_length=16, blank=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions