점프 투 장고 질문 상세 서버 구동 오류
점프 투 장고 질문 상세 구현하기에서 나오는 코드들을 작성하고, 'python manage.py runserver'로 서버를 구동시키려고 하면 오류가
납니다.
pybo -> urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
]
pybo -> views.py
from django.shortcuts import render
from .models import Question
def index(request):
question_list = Question.objects.order_by('-create_date')
context = {'question_list': question_list}
return render(request, 'pybo/question_list.html', context)
def detail(request, question_id):
question = Question.objects.get(id=question_id)
context = {'question': question}
return render(request, 'pybo/question_detail.html', context)
html 부분을 여기서 입력하면 글을 등록하면 이상하게 변해서 구글 문서에 썼습니다.
https://docs.google.com/document/d/1-_FR8sRXml9Jv54KbrHnC_WN7L_9wSWiuY1Aj8Exv-4/edit?usp=sharing
이전 단계 실습은 잘 됬습니다.
오류 메세지
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Program Files\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Program Files\Python311\Lib\threading.py", line 975, in run
self._target(self._args, self._kwargs)
File "C:\h.c website\website\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(args, **kwargs)
File "C:\h.c website\website\Lib\site-packages\django\core\management\commands\runserver.py", line 133, in inner_run self.check(display_num_errors=True)
File "C:\h.c website\website\Lib\site-packages\django\core\management\base.py", line 485, in check
all_issues = checks.run_checks(
^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\utils\functional.py", line 57, in get
res = instance.dict[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
^^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\utils\functional.py", line 57, in get
res = instance.dict[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "C:\h.c website\website\Lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\importlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "
File "
File "
File "
File "
File "
File "C:\h.c website\config\urls.py", line 19, in
from . import views
ImportError: cannot import name 'views' from 'config' (C:\h.c website\config__init__.py)
hc 님 1458
M 2023년 10월 12일 7:37 오후