gpt4 book ai didi

python - 无法识别 Django 错误

转载 作者:行者123 更新时间:2023-11-30 23:40:28 26 4
gpt4 key购买 nike

看到以下语法错误,但 urls.py 文件似乎是正确的。我错过了什么?

SyntaxError at /admin/
invalid syntax (urls.py, line 6)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.4.1
Exception Type: SyntaxError
Exception Value:
invalid syntax (urls.py, line 6)
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2

这是 urls.py:

from django.conf.urls.defaults import *
from events import views

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^events/', include('events.urls')),
(r'^admin/', include(admin.site.root)),
)

...

from django.conf.urls.defaults import *
from events import views

urlpatterns = patterns('',
url(r'^create/$', views.create, name='ev_create')
url(r'^tonight/$', views.tonight, name='ev_tonight'),
)

最佳答案

您缺少一个逗号:

urlpatterns = patterns('',
url(r'^create/$', views.create, name='ev_create') # <-- comma missing
url(r'^tonight/$', views.tonight, name='ev_tonight'),
)

请注意,这是 urls.py 模块的第 5 行,但是当 Python 遇到不适合 url(. ..) 调用。

关于python - 无法识别 Django 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12652353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com