920951018002774
UnYeong Jeong
  • 2016.4.27 21:23
  • 조회수 282
  • 답변수 4
920951018002774
UnYeong Jeong
  • 2016.4.27 21:23
  • 조회수 282
  • 답변수 4

재질문합니다.

여러번 체크를 했는데도 왜 서버가 안돌아가는지 모르겠습니다ㅜㅜ


urls.py의 내용입니다.

from django.conf.urls import url
from . import views #.은 현재 폴더라는 뜻

urlpatterns = [
url(r'$', views.index),
url(r'areas/(?P.+)/$',views.areas)
url(r'polls/(?P\d+)/$', views.polls),
]


오류메시지입니다.

'''
Unhandled exception in thread started by .wrapper at 0x0000015C3E855950>
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in get
res = instance.dict[self.name] = self.func(instance)
File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in get
res = instance.dict[self.name] = self.func(instance)
File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Anaconda3\lib\importlib_init.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "", line 986, in gcd_import
File "", line 969, in findand_load
File "", line 958, in find_and_load_unlocked
File "", line 673, in loadunlocked
File "", line 662, in exec_module
File "", line 222, in call_with_frames_removed
File "C:\dev\mysite\mysite\urls.py", line 20, in
url(r'', include('elections.urls')), #주소, 누가 처리 / include는 앱 실행할 때 추가
File "C:\Anaconda3\lib\site-packages\django\conf\urls
init.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "C:\Anaconda3\lib\importlib
init.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
File "", line 986, in gcd_import
File "", line 969, in _find_and_load
File "", line 958, in find
and_load_unlocked
File "", line 673, in _loadunlocked
File "<frozen importlib.
bootstrapexternal>", line 658, in exec_module
File "", line 764, in get_code
File "", line 724, in source_to_code
File "", line 222, in call_with_frames_removed
File "C:\dev\mysite\elections\urls.py", line 7
url(r'polls/(?P\d+)/$', views.polls),
^
SyntaxError: invalid syntax
'''

  • #장고를 활용한 웹사이트 만들기
  • #여론조사 결과저장

4 답변

  • G3rlasealonpd5c2kica
    Demi
    • 2016.4.27 21:28

    코드를 감쌀 때 '가 아니라 `(물결표시)로 적어주세요

    이렇게 보여야 합니다.
    

    • 음... 제가 잘 이해를 못했는데, urls.py에서 ' 대신 `를 써야한다는 것인지요?-UnYeong Jeong
      2016.4.27 21:30
    • 네 맞습니다-Demi
      2016.4.27 21:39
  • 920951018002774
    UnYeong Jeong
    • 2016.4.27 21:31

    urls.py 내용
    
    from django.conf.urls import url
    from . import views #.은 현재 폴더라는 뜻
    
    urlpatterns = [
    url(r'$', views.index),
    url(r'areas/(?P.+)/$',views.areas)
    url(r'polls/(?P\d+)/$', views.polls),
    ]
    
    오류 메시지
    Unhandled exception in thread started by .wrapper at 0x0000015C3E855950>
    Traceback (most recent call last):
    File "C:\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
    File "C:\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
    File "C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
    File "C:\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
    File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
    File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    for pattern in resolver.url_patterns:
    File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in get
    res = instance.dict[self.name] = self.func(instance)
    File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in get
    res = instance.dict[self.name] = self.func(instance)
    File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
    File "C:\Anaconda3\lib\importlib_init.py", line 126, in import_module
    return bootstrap.gcd_import(name[level:], package, level)
    File "", line 986, in gcd_import
    File "", line 969, in findand_load
    File "", line 958, in find_and_load_unlocked
    File "", line 673, in loadunlocked
    File "", line 662, in exec_module
    File "", line 222, in call_with_frames_removed
    File "C:\dev\mysite\mysite\urls.py", line 20, in 
    url(r'', include('elections.urls')), #주소, 누가 처리 / include는 앱 실행할 때 추가
    File "C:\Anaconda3\lib\site-packages\django\conf\urlsinit.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
    File "C:\Anaconda3\lib\importlibinit.py", line 126, in import_module
    return bootstrap.gcd_import(name[level:], package, level)
    File "", line 986, in gcd_import
    File "", line 969, in _find_and_load
    File "", line 958, in findand_load_unlocked
    File "", line 673, in _loadunlocked
    File "<frozen importlib.bootstrapexternal>", line 658, in exec_module
    File "", line 764, in get_code
    File "", line 724, in source_to_code
    File "", line 222, in call_with_frames_removed
    File "C:\dev\mysite\elections\urls.py", line 7
    url(r'polls/(?P\d+)/$', views.polls),
    ^
    SyntaxError: invalid syntax
    

    • 위에 코드를 ```로 감싸는게 아니라 새로 실행하고 복사붙여넣기 해주셔야 합니다. 원래 오류 메시지 Unhandled exception in thread started by .wrapper at 0x0000015C3E855950>에서 by 뒤에 <>가 더 있어야 하는데 작성하신 곳은 해당 사항이 안보이네요-Demi
      2016.4.27 21:34
    • Unhandled exception in thread started by <pydev_monkey._NewThreadStartupWithTrace object at 0x0000000004D682B0> 이런식으로 by <....> 이렇게 나오는게 맞습니다-Demi
      2016.4.27 21:34
    • markdown문법은 http://hashcode.co.kr/questions/1772/ 에서 보실수 있습니다.-Demi
      2016.4.27 21:36
  • 920951018002774
    UnYeong Jeong
    • 2016.4.27 21:46

    앗 이제 이해했습니다.

    <function check_errors.<locals>. 이게 빠져있네요!
    
    Performing system checks...
    
    Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000163FCC05950>
    Traceback (most recent call last):
      File "C:\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
        fn(*args, **kwargs)
      File "C:\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
        self.check(display_num_errors=True)
      File "C:\Anaconda3\lib\site-packages\django\core\management\base.py", line 426, in check
        include_deployment_checks=include_deployment_checks,
      File "C:\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
        new_errors = check(app_configs=app_configs)
      File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
        return check_resolver(resolver)
      File "C:\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
        for pattern in resolver.url_patterns:
      File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
        patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
      File "C:\Anaconda3\lib\site-packages\django\utils\functional.py", line 33, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "C:\Anaconda3\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
        return import_module(self.urlconf_name)
      File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        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 662, in exec_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "C:\dev\mysite\mysite\urls.py", line 20, in <module>
        url(r'^', include('elections.urls')), #주소, 누가 처리 / include는 앱 실행할 때 추가
      File "C:\Anaconda3\lib\site-packages\django\conf\urls\__init__.py", line 52, in include
        urlconf_module = import_module(urlconf_module)
      File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
        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 658, in exec_module
      File "<frozen importlib._bootstrap_external>", line 764, in get_code
      File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "C:\dev\mysite\elections\urls.py", line 7
        url(r'^polls/(?P<poll_id>\d+)/$', views.polls),
          ^
    SyntaxError: invalid syntax
    
    

  • Gscxhpxkg5i74t30rimh
    정두식
    • 2016.4.27 23:55

    6번째 줄 마지막에 ,이 빠졌네요.

    • 감사합니다. 계속 아래 문장만 보고 있었네요ㅜㅜ-UnYeong Jeong
      2016.4.28 09:18

답변 쓰기

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