Open happysms opened 3 years ago
hello는 app이기 때문에 디렉터리로 존재해야 하는데 urls.py 경로에는 문제가 없는 것 같고 urls.py의 내용이 아래와 같다면 hello/views.py 파일의 경로를 확인해 보시기 바랍니다.
C:\mySite\Investar\Investar\urls.py
from django.contrib import admin
from django.urls import path, re_path
from hello import views
from index import views as index_views
from balance import views as balance_views
urlpatterns = [
path('admin/', admin.site.urls),
re_path(r'^(?P<name>[A-Z][a-z]*)$', views.sayHello),
path('index/', index_views.main_view),
path('balance/', balance_views.main_view),
]
C:\mySite\Investar\hello\views.py
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def sayHello(request, name):
html = "<h1>Hello, {}!</h1>".format(name)
return HttpResponse(html)
제가 테스트한 캡처 그림은 아래와 같습니다. django 서버를 실행시키는 방법과 각각의 app을 실행하는 모습을 캡처하였습니다.
제 PC의 C:/mySite 폴더를 통째로 압축해서 업로드 해드리니 파일 내용과 경로를 참고하시기 바랍니다. mySite.zip
본 이슈는 다른 독자님들에게도 유용한 내용인 것 같아서 종료하지 않고 남겨두는 것이 좋겠습니다.
7.2.5 부분에서 소스코드를 그대로 받아적고 실행을 시켰을 때 hello라는 모듈은 없다고 오류가 나오네요... 그래서 C:\mySite\Investar에 있는 hello 파일을 C:\mySite\Investar\Investar로 옮기니 File "c:/mySite/Investar/Investar/urls.py", line 21, in
path('admin/', admin.site.urls),
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\utils\functional.py", line 240, in inner
self._setup()
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\contrib\admin\sites.py", line 540, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\apps\registry.py", line 154, in get_app_config
self.check_apps_ready()
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\apps\registry.py", line 135, in check_apps_ready
settings.INSTALLED_APPS
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\conf__init.py", line 82, in getattr__
self._setup(name)
File "C:\Users\user.conda\envs\minsung\lib\site-packages\django\conf__init__.py", line 67, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment varnt variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
이런 오류가 발생하네요.. 어떤 것이 문제일지 알 수 있을까요?