Skip to content

Other options are ignored by migration algorithm #570

Open
@ClundXIII

Description

@ClundXIII

Lets take a model like this:

class Test(PolymorphicModel):
  created_date = models.DateTimeField(default=timezone.now)

  class Meta:
    ordering = ['-created_date']

With an initial migration:

        migrations.CreateModel(
            name='Test',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_date', models.DateTimeField(default=django.utils.timezone.now)),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
                'ordering': ['-created_date'],
            },
        ),

Note, that I merged the order and polymorphic options together. Unfortunately django fails to recognize the ordering option and will create this migrations when running makemigrations;

        migrations.AlterModelOptions(
            name='Test',
            options={'ordering': ['-created_date']},
        ),

This is not a big deal and an has an easy workaround just appending the options below. However my guess would be that there is some super() call missing inside the Polymorphic handling of CreateModel. So this might be a symptom of an issue that is deep down in the code.

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