0

在我网站的主 urls.py 文件中,我试图添加这一行:

url(r'^account/',include('accounts.urls', namespace='accounts')),

添加该行后,我的文件如下所示:

from django.conf.urls import patterns, include, url
from invest1.views import *

#to enable admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',

    url(r'^$', 'invest1.views.home', name='home'),
    url(r'^about/$', 'invest1.views.about', name='about'),
    url(r'^contact/$', 'invest1.views.contact_us', name='contact'),

    url(r'^account/', include('accounts.urls', namespace='accounts')),
    url(r'^profile/', include('profiles.urls', namespace='profiles')),
    url(r'^post/', include('posts.urls', namespace='posts')),

    #uncomment to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    #to enable admin
    url(r'^admin/', include(admin.site.urls)),
)

无论我对文件做什么,我都会收到错误消息

SyntaxError at /
invalid syntax (urls.py, line 18)

注释掉帐户行后,网站运行。但无论我把这条线放在哪里,它总是给我同样的错误和相同的行号。我什至重新输入了整个内容以确保它不是一些非法的空白字符。我觉得我错过了一些非常微不足道的东西......导致错误的原因是什么?

4

1 回答 1

0

问题可能出在另一个urls.py(例如accounts.urls)中。

于 2012-12-28T08:36:59.433 回答