【发布时间】:2011-09-24 15:38:39
【问题描述】:
我正在使用 Django 1.2.3-3+squeeze1 和 Debian 挤压。
我正在尝试在我的应用程序中使用 Django 密码更改视图
对应于django.contrib.auth.views.password_change。这
看起来应该很简单,但我一直有
问题。
为了简单和完整,我将指向我的应用程序文件 在线的。该应用程序是bixfile。这 对应的Django项目是bixproj。
url.py 中的相关行是 https://bitbucket.org/faheem/bixfile/src/49bcbab3a7be/urls.py#cl-65, 即
url(r'^password_change/$', 'django.contrib.auth.views.password_change', {'post_change_redirect':reverse('top_folders')}, name="password_change"),
这会破坏使用它的任何模板。目前,我只是 在线使用它 https://bitbucket.org/faheem/bixfile/src/71de33d01f43/templates/calgb_base.html#cl-21 模板 calgb_base.html,包含在一堆 模板包括顶级索引视图,对应于 模板 https://bitbucket.org/faheem/bixfile/src/71de33d01f43/templates/index.html。这 calgb_base.html 中的行是
<li><a class="side" href="{% url password_change %}">Password Change</a></li>
当我导航到顶部index 视图对应于
https://bitbucket.org/faheem/bixfile/src/71de33d01f43/urls.py#cl-16
和
https://bitbucket.org/faheem/bixfile/src/71de33d01f43/views.py#cl-203
我看到一个错误,以
Caught NoReverseMatch while rendering: Reverse for 'password_change'
with arguments '()' and keyword arguments '{}' not found.
我怀疑完整的回溯是否有用,但我已将其粘贴在 http://paste.lisp.org/display/122996.
Apache 2.2 和 mod-wsgi 也可以重现此错误 作为内置的 Django 测试服务器(见下文)。
如果我直接访问 /password_change/ 相对 url,我会看到 密码更改表单符合预期。
奇怪的是,我编写的所有测试都是为了测试这个 通过,并产生预期的结果。参见例如 testIndexUrl , testIndexView 和 test_password_change_url.
您可以从 bixproj 目录运行测试
python manage.py test
如果您想尝试重现此错误,则相对容易。
首先下载项目(bixproj)和应用程序库
(bixfile)。所以
hg clone ssh://hg@bitbucket.org/faheem/bixproj
hg clone ssh://hg@bitbucket.org/faheem/bixfile
然后确保 bixfile 在 Python 路径中。更改要使用的数据库 sqlite。然后改变
LOGIN_URL = '/'+BIXFILE_NAME+'/login/'
LOGIN_REDIRECT_URL= '/'+BIXFILE_NAME+'/'
到
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL= '/'
然后运行
python manage.py runserver
在本地计算机上的 bixproj 目录中并转到默认 url
http://127.0.0.1:8000/ 应该会显示错误。
我希望我可以生成一个显示错误的最小示例,如果 有必要,但我真的希望这个错误很明显,我不 不得不。提前致谢。
【问题讨论】:
标签: django django-templates django-urls django-generic-views