0
我正在从python2.5迁移到python 2.7,并遇到数据库索引问题。主要就是页面正确生成,但没有收到这个错误,我不能做与数据库(添加条目)的任何操作:TemplateSyntaxError在迁移到python 2.7后
TemplateSyntaxError at /new
Caught NoReverseMatch while rendering: Reverse for 'views.edit' with
arguments '('',)' and keyword arguments '{}' not found.
Request Method: GET
Exception Type: TemplateSyntaxError
Exception Value:
Caught NoReverseMatch while rendering: Reverse for 'views.edit' with
arguments '('',)' and keyword arguments '{}' not found.
Exception Location: /Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-
1.2/django/template/defaulttags.py in render, line 385
Template error
In template /.../templates/item.html, error at line 5
Caught NoReverseMatch while rendering: Reverse for 'views.edit' with
arguments '('',)' and keyword arguments '{}' not found.
下面是我在5号线:
<form action="{%url views.edit item.key.id%}" method="post">
我的urls.py包含:
urlpatterns = patterns('',
(r'^$', 'views.index'),
(r'^new$', 'views.new'),
(r'^edit/(\d+)$', 'views.edit'),
)
它好工作与Python 2.5
如果有这样的改变呢? urlpatterns = patterns( '', (r'^ $','views.index'), (r'^ new $','views.new'), (r'^ edit /(\ d +) $','views.edit'), ) – Tyra
这真的要取决于,但是如果您将编辑模式中的'+'更改为'*',则它将匹配。至于如果那能完全解决你的问题,我不确定。 –
谢谢!它像一个魅力! – Tyra