问题
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