我有一个我无法检测到的错误,我正在学习 Django,一开始我正在使用 Django 默认用户模型,但后来我需要一个自定义用户模型,所以我删除了我的 db(已删除 sqlite db 文件) ,在models.py中创建新的用户模型,然后makemigrations然后迁移它。但是,当我切换到管理页面时,我遇到了一个我无法解决的错误。我得到的错误是:
django.db.utils.OperationalError:没有这样的表:IEL_user
模型.py 文件
class user(AbstractUser):
is_student=models.BooleanField(default=False)
is_teacher=models.BooleanField(default=False)
我在 settings.py 中添加了 AUTH_USER_MODEL = 'IEL.user'
错误是:
Internal Server Error: /admin/
Traceback (most recent call last):
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\db\backends\sqlite3\base.py", line 303, in
execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: IEL_user
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
response = get_response(request)
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\core\handlers\base.py", line 128, in
_get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\core\handlers\base.py", line 126, in
_get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Nabeel Ayub\AppData\Local\Programs\Python\Python35-
32\lib\site-packages\django\contrib\admin\sites.py", line 241, in wrapper
return self.admin_view(view, cacheable)(*args, **kwargs)