Пытаюсь создать простой блог на джанго, сделал проект, сделал приложение.
Запустил, все работает. Прописал в сеттинг свой блог:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog'
]
Прописал в urls.py ссылки на блог
from django.contrib import admin
from django.urls import path
from django.urls import include
urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('blog.urls'))
Создал urls.py в приложении и там прописал
from django.urls import path
from .views import *
urlpatterns = [
path('', posts_list)
]
В приложении во view.py прописал:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def posts_list(request):
return HttpResponse('<h1> Hello Word </h1>')
При запуске сервера получаю длинную ошибку, в конце LookupError: No installed app with label 'admin'.
Полный текст:
Traceback (most recent call last):
File "C:\Users\ugrobug\PycharmProjects\site\venv\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 "C:\Users\ugrobug\PycharmProjects\site\blogengiene\manage.py", line 21, in <module>
main()
File "C:\Users\ugrobug\PycharmProjects\site\blogengiene\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\ugrobug\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ugrobug\PycharmProjects\site\blogengiene\blogengiene\urls.py", line 22, in <module>
path('admin/', admin.site.urls),
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup()
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "C:\Users\ugrobug\PycharmProjects\site\venv\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.