jafarlihi
jafarlihi

Reputation: 100

Why is migration for removing a base class from a model fails?

I've got this model that inherits from another:

from postman import models

class Message(models.Message):
    subclass_field = TextField(blank=True, null=True)

Now when I remove the base class postman.models.Message and run makemigrations I get this:

    operations = [
        migrations.RemoveField(
            model_name='message',
            name='message_ptr',
        ),
        migrations.AddField(
            model_name='message',
            name='id',
            field=models.AutoField(auto_created=True, default=1, primary_key=True, serialize=False, verbose_name='ID'),
            preserve_default=False,
        ),
    ]

Now the only issue is that when running it it says this:

django.core.exceptions.FieldError: Local field 'id' in class 'Message' clashes with field of the same name from base class 'Message'.

Am I doing something wrong?

This is a pretty basic case of removing base model from a model, you'd think it would work -- why is it not working?

Upvotes: 1

Views: 92

Answers (1)

Nikunj
Nikunj

Reputation: 315

class DiraiveMessage(models.Message)

Try This

change class name Message

Upvotes: 1

Related Questions