Django Invalid Syntax Error

与世无争的帅哥 提交于 2021-01-28 06:34:32

问题


I am at my wits. I am trying to set up Django admin but I am having a hard time. I have followed the Django book and checked several times but get an invalid syntax (urls.py, line 23).

from django.conf.urls.defaults import *
from mysite.views import hello, current_datetime, hours_ahead

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^hello/$', hello),
    (r'^time/$', current_datetime),
    (r'^time/plus/(\d{1,2})/$', hours_ahead),
    (r'^admin/', include(admin.site.urls), 
)

Any insight would be appreciated - thanks!


回答1:


You are missing a closing parens on line 22:

(r'^admin/', include(admin.site.urls)), 

When you get a SyntaxError in Python, check that your parenthesis are balanced on the lines preceding it.



来源:https://stackoverflow.com/questions/13565099/django-invalid-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!