django中的语法错误
Posted
技术标签:
【中文标题】django中的语法错误【英文标题】:Syntax Error in django 【发布时间】:2011-07-30 12:25:21 【问题描述】:是什么导致了这个 urls.py 中的语法错误?
上面写着
syntax error at Line 27[(r'^xd_receiver\.html$',.....] in ursl.py.
我不知道问题出在哪里。
urlpatterns = patterns('',
# Example:
# (r'^universityDB/', include('universityDB.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
(r'^registrationForm/$','universityDB.universityDetails.views.registrationForm'),
(r'^userDetails/$','universityDB.universityDetails.views.userDetails'),
(r'^login/$','universityDB.universityDetails.views.login'),
(r'^userCreated/$','universityDB.universityDetails.views.userCreated'),
(r'^forgotPassword/$','universityDB.universityDetails.views.forgotPassword'),
(r'^passwordRecovery/$','universityDB.universityDetails.views.passwordRecovery'),
(r'^accounts/profile', 'universityDB.universityDetails.views.profile'),
(r'^xd_receiver\.html$', direct_to_template, 'template': 'xd_receiver.html', name='xd_receiver'),
(r'^login_facebook_connect/$', 'login_facebook_connect', name='facebook_connect_ajax'),
)
【问题讨论】:
【参考方案1】:如果你想命名你的网址,你必须使用url(...)
function,即
url(r'^xd_receiver\.html$', direct_to_template, 'template': 'xd_receiver.html', name='xd_receiver')
……而不是:
(r'^xd_receiver\.html$', direct_to_template, 'template': 'xd_receiver.html', name='xd_receiver')
【讨论】:
一个澄清没有强制或必须使用url()
。你可以简单地写(r'^xd_receiver\.html$', direct_to_template, 'template': 'xd_receiver.html', 'xd_receiver')
可以正常工作(使用元组)以上是关于django中的语法错误的主要内容,如果未能解决你的问题,请参考以下文章
缺少变量值时 Django 模板中的 Javascript 语法错误