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 comment

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