Issue
I will give all of you the step that I do before this error happen
btw my superuser=>id:myuser email: pass:myuser
hostname $ django-admin.py startproject myproj
hostname $ cd myproj
hostname $ python manage.py startapp myapp
hostname $ python manage.py migrate
hostname $ python manage.py createsuperuser
hostname $ python manage.py runserver
hostname $ pip install psycopg2
hostname $ psql
postgres=# create role myuser with createdb superuser
login password 'myuser';
postgres=# create database mydb with owner myuser;
postgres=# exit
and then I edit the myproj\settings.py, and I run command python manage.py makemigrations myapp and the error bellow happen
Traceback (most recent call last):
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'admin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 366, in execute
self.check()
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\myproj\myproj\urls.py", line 20, in <module>
path('admin/', admin.site.urls),
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 224, in inner
self._setup()
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\admin\sites.py", line 537, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.
this is the only file that I modify
myproj/settings.py
import os
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'zl@b!)%627#jp-sa40v&yscmvd8r#f^^vi(45z)sqg-c2=o*-e'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
# Third party apps
'rest_framework',
'rest_framework.authtoken',
# Internal apps
'myapp',
]
MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'myproj.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'myproj.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER': 'myuser',
'PASSWORD': 'myuser',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
Is there anything that I can do??? did I miss something???I'm trying to use an older version django like 2.2.10 but it stil didnt work, when this error happen I used a new version of django and python as well as postgresql too
Solution
Your application is importing admin, but the Django admin is not present in your settings.py.
Add it in INSTALLED_APPS
:
INSTALLED_APPS = [ 'django.contrib.admin', 'your.other.applications.follow']
Answered By - ionpoint
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.