Python 渲染时的NoReverseMatch:对于';视图。showusersignin';带参数';()';和关键字参数';{';用户ID';:u';rec.0';}';找不到

Python 渲染时的NoReverseMatch:对于';视图。showusersignin';带参数';()';和关键字参数';{';用户ID';:u';rec.0';}';找不到,python,django,django-templates,Python,Django,Django Templates,我看了很多关于stackoverflow的讨论,但是没有一个有用。所以我决定把我的代码粘贴在这里。所以请帮我找出哪里做错了。谢谢 这里是url.py (r'^showusersignin/(?P<userid>\d+)/$', 'views.showusersignin'), def showusersignin(request,userid): 这里是sign.html {%for rec in records.object_list%} <tr>

我看了很多关于stackoverflow的讨论,但是没有一个有用。所以我决定把我的代码粘贴在这里。所以请帮我找出哪里做错了。谢谢

这里是url.py

(r'^showusersignin/(?P<userid>\d+)/$', 'views.showusersignin'),
def showusersignin(request,userid):
这里是sign.html

{%for rec in records.object_list%}

        <tr>
            <td width = "15%">
               <a href="{%url views.showusersignin userid='rec.0' %}">{{rec.0}}</a>
            </td>
            <td width = "15%">
                {{rec.1}}
            </td>
            <td width = "15%">
                {{rec.2}}
            </td>

        </tr>
 {%endfor%}

你做错了两件事

首先,您将
'rec.0'
作为字符串放入url标记中。我假定您的意思是传递该列表项的值,因此您应该执行
userid=rec.0


其次,您的URL没有
userid
参数,因为您没有使用命名参数。将其更改为
r'^showusersignin/(?P\d+)/$”
,或将url标记更改为
{%url views.showusersignin rec.0%}

url.py
的初始部分粘贴到执行
urlpatterns=patterns>操作的位置(…
我的猜测是,您没有在那里指定正确的应用程序。另一种可能性是:
-因为您指定了
userid=
django认为kwarg,而不是必需的参数
Request Method: GET
Request URL:    mysite/signin
Django Version: 1.2.5
Exception Type: TemplateSyntaxError
Exception Value:    
Caught NoReverseMatch while rendering: Reverse for 'views.showusersignin' with arguments '()' and keyword arguments '{'userid': u'rec.0'}' not found.
Exception Location: /base/python27_runtime/python27_lib/versions/third_party/django-1.2/django/template/defaulttags.py in render, line 385
Python Executable:  /base/python27_runtime/python27_dist/python
Python Version: 2.7.3
Python Path:    ['/base/data/home/apps/s~bgshelloworld/9.363836595528814694', '/base/data/home/apps/s~bgshelloworld/9.363836595528814694', '/base/python27_runtime/python27_dist/lib/python27.zip', '/base/python27_runtime/python27_dist/lib/python2.7', '/base/python27_runtime/python27_dist/lib/python2.7/plat-linux2', '/base/python27_runtime/python27_dist/lib/python2.7/lib-tk', '/base/python27_runtime/python27_dist/lib/python2.7/lib-old', '/base/python27_runtime/python27_dist/lib/python2.7/lib-dynload', '/base/python27_runtime/python27_dist/lib/python2.7/site-packages', '/base/python27_runtime/python27_lib/versions/1', '/base/python27_runtime/python27_lib/versions/third_party/django-1.2', '/base/python27_runtime/python27_lib/versions/third_party/jinja2-2.6', '/base/python27_runtime/python27_lib/versions/third_party/markupsafe-0.15', '/base/python27_runtime/python27_lib/versions/third_party/setuptools-0.6c11', '/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3', '/base/python27_runtime/python27_lib/versions/third_party/webob-1.1.1', '/base/python27_runtime/python27_lib/versions/third_party/yaml-3.10']
Server time:    Thu, 13 Dec 2012 11:11:23 +0000