I am pretty new to Django and I was just following along witht the tutorial. I was making a project from https://github.com/justdjango/getting-started-with-django, and after I added users and a superuser, I started to get a Traceback like this:
Traceback (most recent call last):
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\auth\__init__.py", line 160, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\apps\registry.py", line 204, in get_model
app_label, model_name = app_label.split('.')
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Dell\Desktop\prog\manage.py", line 22, in <module>
main()
File "C:\Users\Dell\Desktop\prog\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
self.module.autodiscover()
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\admin\__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\auth\admin.py", line 6, in <module>
from django.contrib.auth.forms import (
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\auth\forms.py", line 21, in <module>
UserModel = get_user_model()
File "C:\Users\Dell\Desktop\prog\programa\lib\site-packages\django\contrib\auth\__init__.py", line 162, in get_user_model
raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL must be of the form 'app_label.model_name'
CodePudding user response:
You forgot to specify the model name in the AUTH_USER_MODEL
setting. If you defined a model User
in the leads
app, you thus set this with:
# settings.py
# app name ↓
AUTH_USER_MODEL = 'leads.User'
# model name ↑