Home > Net >  I try to create a superuser but the error is no such table: users_user
I try to create a superuser but the error is no such table: users_user

Time:09-21

the error is :

django.db.utils.OperationalError: no such table: users_user

this is my model:

class User(AbstractUser):
pass

the settings:

AUTH_USER_MODEL = 'users.User'

CodePudding user response:

Delete all migrations then... apply below commands

python manage.py makemigrations yourapp_name
python manage.py migrate

CodePudding user response:

First delete all migrations file and then add below code and then do migrations

try this:

    from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin   
    class User(AbstractBaseUser, PermissionsMixin):
             pass

CodePudding user response:

You may need to remove the migration folders of your apps and then type the following to reset all admin, auth, contenttypes, and sessions from the migration history and drop the tables:

python manage.py migrate admin zero
python manage.py migrate auth zero
python manage.py migrate contenttypes zero
python manage.py migrate sessions zero

Then, just do makemigrations users and migrate users.

  • Related