강의로 돌아가기
김세창

질문 계속 오류가 나네요..

---------------elections.urls.py---------------
from django.urls import path, include
from . import views

urlpatterns = [
path('', views.index),
]

---------------elections.views.py---------------
from django.shortcuts import render
from dajngo.http import HttpResponse

def index(request):
return HttpResponse(Hello world)

---------------mysite.urls.py---------------
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('elections.urls')),
]

-------------오류내용-------------------
Unhandled exception in thread started by .wrapper at 0x060514F8>
Traceback (most recent call last):
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py, line 225, in wrapper
fn(args, **kwargs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py, line 120, in inner_run
self.check(display_num_errors=True)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py, line 364, in check
include_deployment_checks=include_deployment_checks,
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py, line 351, in _run_checks
return checks.run_checks(
*kwargs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py, line 73, in run_checks
new_errors = check(app_configs=app_configs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py, line 13, in check_url_config
return check_resolver(resolver)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py, line 23, in check_resolver
return check_method()
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 397, in check
for pattern in self.url_patterns:
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 536, in url_patterns
patterns = getattr(self.urlconf_module, urlpatterns, self.urlconf_module)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 529, in urlconf_module
return import_module(self.urlconf_name)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py, line 126, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File , line 994, in _gcd_import
File , line 971, in _find_and_load
File , line 955, in _find_and_load_unlocked
File , line 665, in _load_unlocked
File , line 678, in exec_module
File , line 219, in _call_with_frames_removed
File C:\Users\chang\django\mysite\mysite\urls.py, line 21, in
path('', include('elections.urls')), #elections app을 include 해주는것임.
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\conf.py, line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\importlib__init
_.py, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File
, line 994, in _gcd_import
File
, line 971, in _find_and_load
File
, line 955, in _find_and_load_unlocked
File
, line 665, in _load_unlocked
File
, line 678, in exec_module
File
, line 219, in _call_with_frames_removed
File
C:\Users\chang\django\mysite\elections\urls.py, line 2, in
from . import views #.은 현재폴더의 디렉토리라는뜻. 즉 현재폴더의 views.py를 import하는것임
File
C:\Users\chang\django\mysite\elections\views.py", line 2, in
from dajngo.http import HttpResponse
ModuleNotFoundError: No module named 'dajngo'
PS C:\Users\chang\django\mysite> python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrapper at 0x05FA14F8>
Traceback (most recent call last):
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py, line 225, in wrapper
fn(args, **kwargs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py, line 120, in inner_run
self.check(display_num_errors=True)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py, line 364, in check
include_deployment_checks=include_deployment_checks,
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py, line 351, in _run_checks
return checks.run_checks(
*kwargs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py, line 73, in run_checks
new_errors = check(app_configs=app_configs)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py, line 13, in check_url_config
return check_resolver(resolver)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py, line 23, in check_resolver
return check_method()
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 397, in check
for pattern in self.url_patterns:
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 536, in url_patterns
patterns = getattr(self.urlconf_module, urlpatterns, self.urlconf_module)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py, line 529, in urlconf_module
return import_module(self.urlconf_name)
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py, line 126, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File , line 994, in _gcd_import
File , line 971, in _find_and_load
File , line 955, in _find_and_load_unlocked
File , line 665, in _load_unlocked
File , line 678, in exec_module
File , line 219, in _call_with_frames_removed
File C:\Users\chang\django\mysite\mysite\urls.py, line 21, in
path('', include('elections.urls')),
File C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\conf.py, line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\chang\AppData\Local\Programs\Python\Python36-32\lib\importlib__init
_.py, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File
, line 994, in _gcd_import
File
, line 971, in _find_and_load
File
, line 955, in _find_and_load_unlocked
File
, line 665, in _load_unlocked
File
, line 678, in exec_module
File
, line 219, in _call_with_frames_removed
File
C:\Users\chang\django\mysite\elections\urls.py, line 2, in
from . import views
File
C:\Users\chang\django\mysite\elections\views.py", line 2, in
from dajngo.http import HttpResponse
ModuleNotFoundError: No module named 'dajngo'

1 개의 답변
김효진

---------------elections.views.py---------------
from django.shortcuts import render
from dajngo.http import HttpResponse

def index(request):
return HttpResponse(Hello world)

함수에서
def index(request):
return HttpResponse(Hello world) # 이 줄 들여쓰기 오류 인것같아요

답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다. 마크다운 가이드 를 참고하세요.