강의로 돌아가기
조성륜

NameError: name 'index' is not defined

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03CF6300>
Traceback (most recent call last):
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", li
ne 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands
\runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py"
, line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py"
, line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\registry.py"
, line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", li
ne 14, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", li
ne 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", li
ne 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py", line
 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", li
ne 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\urls\resolvers.py", line
 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\joseongryun\Desktop\수업\파이썬\django\mysite\mysite\urls.py", line 5, in <module>
    url(r'^', include('elections.urls')),
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\urls\__init__.py",
line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\joseongryun\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\joseongryun\Desktop\수업\파이썬\django\mysite\elections\urls.py", line 4, in <module>
    url(r'^$',views,index)
NameError: name 'index' is not defined
1 개의 답변
프로그래머스

url(r'^$',views.index)이 아니라 url(r'^$',views,index)로 쓰신 것 같은데요.
콤마를 점으로 바꿔보세요.

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