在我网站的主要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)
帐户行已注释掉,网站运行。但无论我把线放在哪里,它总是给我同样的错误和相同的行号。我甚至重新整理了整件事,以确保它不是一些非法的空白角色。我觉得我错过了一些非常微不足道的东西......导致错误的原因是什么?
答案 0 :(得分:0)
问题可能在另一个问题urls.py
(例如accounts.urls
)。