简体   繁体   English

Django urls.py中的语法错误

[英]Syntax Error in Django urls.py

I'm having a frustrating time installing a very simple recipes website for myself using Django. 使用Django为自己安装一个非常简单的食谱网站时,我感到沮丧。 Everything has been going fine until I attempt to set up my urls.py, which reads: 一切正常,直到我尝试设置urls.py为止:

from django.conf.urls.defaults import *
from django.contrib import admin
from timsrecipes.recipes import views
admin.autodiscover()


urlpatterns = patterns('',
      (r'^index/$', views.index),
      (r'^search/$',views.search),
      (r'^ingredientsearch/$', views.ingredientsearch),
      (r'^admin/', include(admin.site.urls)),
)

The database containing the recipes has been set up, validated, and synchronized, but when I attempt to access any of the webpages, I get the following error message: 包含配方的数据库已设置,验证和同步,但是当我尝试访问任何网页时,出现以下错误消息:

Exception Value: ('invalid syntax', ('/Users/mary/Programming-Startup/timsrecipes/../timsrecipes/recipes/views.py', 13, 10, ' )\\n')) 异常值:(“无效语法”,(“ / Users / mary / Programming-Startup / timsrecipes /../ timsrecipes / recipes / views.py”,13、10,“)\\ n”))

Exception Location: /Users/mary/Programming-Startup/timsrecipes/../timsrecipes/urls.py in , line 3 例外位置:第3行中的/Users/mary/Programming-Startup/timsrecipes/../timsrecipes/urls.py

I really cannot see what the syntax error is here. 我真的看不到这里的语法错误。 Several other small websites I've built have this same formula for importing their views, so I cannot understand what the problem could be. 我建立的其他几个小型网站也使用相同的公式来导入其视图,因此我无法理解问题所在。

例外不在urls.py中,而是在recipes / views.py中的第13行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM