Django AUTH_USER_MODEL refers to model 'powerlistapp.appuser' that has not been installed ERROR

25 Views Asked by At

i have model as in below

from django.db import models
from django.contrib.auth.models import AbstractUser

class AppUser(AbstractUser):
    user_department = models.CharField(max_length=100)
    user_group_email = models.EmailField(max_length=100)
    user_company_id = models.CharField(max_length=8)

    def __str__(self):
        return f"{self.username} {self.last_name} {self.user_department}"

class PowerCustomer(models.Model):  
    customer_name = models.CharField(max_length=100)
    customer_surname = models.CharField(max_length=100)
    customer_birth_date = models.DateField()
    customer_phone_number = models.CharField(max_length=50)
    customer_email = models.EmailField()
    customer_origin_country = models.CharField(max_length=100)
    customer_has_high_priority = models.BooleanField(default=False)
    customer_creation_date = models.DateField()
    customer_loyalty_membership_number = models.CharField(max_length=100)
    customer_job_type = models.CharField(max_length=100)
    customer_description = models.CharField(max_length=370)
    user = models.ForeignKey(AppUser, on_delete=models.SET_NULL, null=True, related_name='power_customers')
    

    def __str__(self):
        return f"{self.customer_name} {self.customer_surname} {self.customer_job_type} {self.customer_description}"

and i have properly configured installed apps as in below

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'powerlistapp',
]

and i have configured my Auth user as in below

AUTH_USER_MODEL = 'powerlistapp.AppUser',,

and i receive this error when i want to make my migrations.

    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'powerlistapp.appuser' that has not been installed

i have deleted my database and delete all migrations and re run python3 manage.py makemigrations. etc

2

There are 2 best solutions below

1
Q46 On

Try to run in your terminal:

python manage.py makemigrations powerlistapp

and then

python manage.py migrate

If this solution does not help, could you please send your project structure (dir and file names)

0
Mehmet Hikmet On

to solve the problem i have deleted AUTH_USER_MODEL = 'powerlistapp.AppUser' from my settings. py and after that i made migrations problem solved and after that i have repaste the related code to settings.py this works for me i hope it work for all.