Объект AbstractUser не имеет атрибута 'модель'
Ниже мой
model.py
class CustomUser(AbstractUser):
email = models.EmailField(unique=True, primary_key=True)
Я переопределяю модель пользователя по умолчанию, указав значение для AUTH_USER_MODEL
setting.py
AUTH_USER_MODEL = 'home.CustomUser'
Но когда я запустил сервер, я получил
AttributeError: 'CustomUser' object has no attribute 'model'
В чем проблема в моем коде ??
Мой
django version = 4.0
полное сообщение об ошибке
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\core\management\commands\runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\core\management\base.py", line 438, in check
all_issues = checks.run_checks(
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\core\checks\registry.py", line 77, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\contrib\admin\checks.py", line 54, in check_admin_app
errors.extend(site.check(app_configs))
File "C:\Users\Hello world\Desktop\python\django\django3\lib\site-packages\django\contrib\admin\sites.py", line 95, in check
if modeladmin.model._meta.app_config in app_configs:
AttributeError: 'CustomUser' object has no attribute 'model'