Nach dem Upgrade von Django 1.10 auf 1.11 habe ich ein Problem bekommen, wenn ich so ziemlich alles gemacht habe. Ich kann meinen Server nicht starten und manage.py nicht ausführen.Django LookupError: App 'accounts' hat kein 'User'-Modell
Vor der Aktualisierung habe ich dieses Problem nicht erhalten, daher bin ich mir nicht sicher, was sich seither geändert hat, was zu diesem Problem führen würde.
Ich habe auch schon versucht, die Datenbank zu löschen, nichts hat sich geändert.
Mein settings.py AUTH_USER_MODEL/INSTALLED_APPS:
AUTH_USER_MODEL = 'accounts.User'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts.apps.AccountsConfig',
'forum.apps.ForumConfig',
]
Mein Benutzermodell:
class User(AbstractUser):
profile_picture = models.ImageField(null=True, blank=True)
birth_date = models.DateField(null=True, blank=True)
Der Fehler:
> Failed to get real commands on module "CsForum": python process died with code
1: Traceback (most recent call last):
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 169, in get_model
return self.models[model_name.lower()]
KeyError: 'user'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\__init__.py", line 193, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 205, in get_model
return app_config.get_model(model_name, require_ready=require_ready)
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 172, in get_model
"App '%s' doesn't have a '%s' model." % (self.label, model_name))
LookupError: App 'accounts' doesn't have a 'User' model.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2017.2.1\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in <module>
django.setup()
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\Elian\OneDrive\PycharmProjects\CsForum\accounts\models.py", line 1, in <module>
from django.contrib.auth.admin import UserAdmin
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\admin.py", line 7, in <module>
from django.contrib.auth.forms import (
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\forms.py", line 22, in <module>
UserModel = get_user_model()
File "C:\Users\Elian\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\__init__.py", line 198, in get_user_model
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'accounts.User' that has not been installed
Sie versucht haben, zu definieren 'AUTH_USER_MODEL' nach' INSTALLED_APPS'? – wencakisa
Ja, gleiches Ergebnis. – Elian