1

我很机智。我正在尝试设置 Django 管理员,但我遇到了困难。我已经按照 Django 书进行了多次检查,但语法无效(urls.py,第 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), 
)

任何见解将不胜感激 - 谢谢!

4

1 回答 1

4

您在第 22 行缺少一个结束括号:

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

当你SyntaxError在 Python 中得到 a 时,检查你的括号在它前面的行上是否平衡。

于 2012-11-26T12:46:25.897 回答