I'm making a Django project with Django 3.1.
I was trying to rewrite the User class in Django. This is what I wrote in app_questions/models.py:
import django.contrib.auth.models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
#pass
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app_questions',
]
AUTH_USER_MODEL = 'app_questions.User'
Also I created an superuser before I did these all.
After that I did makemigrations and migrate in the cmd and ran the server. I open the admin page and try to edit the User I created beforehand, but when I click the edit page, this error occured:
OperationalError at /admin/app_questions/user/1/change/
no such table: app_questions_user_groups
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/app_questions/user/1/change/
Django Version: 3.1
Exception Type: OperationalError
Exception Value:
no such table: app_questions_user_groups
Exception Location: C:\Users\*\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py, line 413, in execute
Python Executable: C:\Users\*\AppData\Local\Programs\Python\Python37-32\python.exe
Python Version: 3.7.4
Python Path:
['C:\\Users\\*\\django_sample\\vitural_env\\zeaf',
'C:\\Users\\*\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip',
'C:\\Users\\*\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs',
'C:\\Users\\*\\AppData\\Local\\Programs\\Python\\Python37-32\\lib',
'C:\\Users\\*\\AppData\\Local\\Programs\\Python\\Python37-32',
'C:\\Users\\*\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages']
I found a few posts to solve this. These are methods I tried:
makemigrationsandmigrate(same error)migrate (appname) --fake(same error)- Add things into the
Userclass (error in /admin:no such column) migrate --sync-db(same error)migrate --run-syncdb(same error)$ manage.py (appname) zero(failed:Unknown command)migrate --fake (appname) zero(same error)
They all didn't solve the problem. Posts in 2016 or 2017 seems doesn't work anymore for now.
Any help is appreciated & sorry if this is a duplicated post.