I am building a django web app with a custom user model which extends the AbstractBaseUser. In one of my models I need to use this custom user model:
from accounts.models import User
class History(models.Model):
user = models.ForeignKey(User)
job = models.ForeignKey(Job)
When I try to run the python manage.py makemigrations
command this error message is outputted:
ImportError: cannot import name User
In my settings.py I do the following to let django know that there is a custom user model:
AUTH_USER_MODEL = "accounts.User"
I am puzzled as to what I am doing wrong. Surely there must be a way to import this model that I do not know of. How do I fix this?
I have tried to use the get_user_model() method, however it doesn't work in the model as the models haven't loaded yet. This is therefore not a solution. Any other ideas?
Thank you in advance.