Django TypeError: Cannot create a consistent method resolution order (MRO) for bases // 1-second guide

A small yet useful piece of information inside.

If you didn’t manage to inherit fields of other class:

class Animal(models.Model)
   legs = models.PositiveIntegerField()

class Horse(Animal):
   nickname = models.Charfield(max_length=64)

And you keep getting this error trying to makemigrations:

Cannot create a consistent method resolution
order (MRO) for bases (Model, Animal)

Alter Animal class like this:

class Animal(models.Model)
   legs = models.PositiveIntegerField()
   
   class Meta:
      abstract = True

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.