Search code examples
pythondjangoinheritancecontinuous-integrationcodeship

django user inherited model fail


I have a model inhereting from Auth.User model, this way: class UsuarioWeb(User): # more fields And in Codeship when making tests, it fails with this error:

django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for [] This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth) in an app with no migrations; see https://docs.djangoproject.com/en/1.9/topics/migrations/#dependencies for more (python3_venv)

I understand the error and it could be solved by a OneToOneField. So one question is, Am I doing right inheriting this way? And other, how to solve this error doing this way?


Solution

  • If you are making a custom user model and do not want to use a OneToOneField, make the class inherit AbstractBaseUser instead. This class only includes authentication functions. If, however, you want the regular User model fields included, make your custom class inherit AbstractUser. The user classes are found in django.contrib.auth.models.