Stack Overflow на русском Asked by JopaBoga on November 18, 2021
Подскажите где ошибка, почему не могу запустить?
(untitled) E:Workpythondjangocrm>python manage.py runserver 8008
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libthreading.py", line 916, in _bootstrap_inner
self.run()
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libthreading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementcommandsrunserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementbase.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementbase.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "C:UsersEgoruntitledlibsite-packagesdjangocorechecksregistry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:UsersEgoruntitledlibsite-packagesdjangocorechecksurls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:UsersEgoruntitledlibsite-packagesdjangocorechecksurls.py", line 23, in check_resolver
return check_method()
File "C:UsersEgoruntitledlibsite-packagesdjangourlsresolvers.py", line 399, in check
for pattern in self.url_patterns:
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsfunctional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:UsersEgoruntitledlibsite-packagesdjangourlsresolvers.py", line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsfunctional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:UsersEgoruntitledlibsite-packagesdjangourlsresolvers.py", line 577, in urlconf_module
return import_module(self.urlconf_name)
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libimportlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "E:Workpythondjangocrmdjangocrmurls.py", line 20, in <module>
path('', include('blog.urls')),
File "C:UsersEgoruntitledlibsite-packagesdjangourlsconf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libimportlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'blog.urls'
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagement__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagement__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementbase.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementcommandsrunserver.py", line 60, in execute
super().execute(*args, **options)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementbase.py", line 364, in execute
output = self.handle(*args, **options)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementcommandsrunserver.py", line 95, in handle
self.run(**options)
File "C:UsersEgoruntitledlibsite-packagesdjangocoremanagementcommandsrunserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 301, in run
self.run_loop()
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 307, in run_loop
next(ticker)
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 347, in tick
for filepath, mtime in self.snapshot_files():
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 363, in snapshot_files
for file in self.watched_files():
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:UsersEgoruntitledlibsite-packagesdjangoutilsautoreload.py", line 139, in iter_modules_and_files
if not path.exists():
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libpathlib.py", line 1314, in exists
self.stat()
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libpathlib.py", line 1136, in stat
return self._accessor.stat(self)
File "C:UsersEgorAppDataLocalProgramsPythonPython36-32libpathlib.py", line 387, in wrapped
return strfunc(str(pathobj), *args)
OSError: [WinError 123] Синтаксическая ошибка в имени файла, имени папки или метке тома: '<frozen importlib._bootstrap>'
Это settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls.apps.PollsConfig',
'blog',
]
Это urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('blog.urls')),
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
Это blog/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='home'),
]
Это blog/views.py
from django.shortcuts import render
def home(request):
return render(request, "partial/home.html")
Проверь есть ли у тебя файл __init__.py
в папке blog. Настоятельно советую следовать оф. документации при первом знакомстве с django:
https://docs.djangoproject.com/en/2.2/intro/tutorial01/
Answered by helenko11 on November 18, 2021
В файле urls.py (который НЕ blog/urls.py) в строке path('', include('blog.urls'))
вы пытаетесь сделать переход на домашнюю страницу сайта, я рекомендую вам попробовать обойтись без include(), т.к. это весьма плохая практика, которая приводит к некорректной работе приложения. Просто сделайте так: path('здесь можете либо оставить пустые кавычки, либо вписать свой url', ваша_функция)
импортируйте вьюху из этой же директории и сделайте роутинг через неё.
Answered by Gasplyak on November 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP