Py学习  »  问与答

一个问题:Caught NoReverseMatch while rendering: u'myapp' is not a registered namespace

ithelloworld • 12 年前 • 7882 次点击  

Django 1.3

app/myapp/urls.py

from django.conf.urls.defaults import patterns, url

urlpatters = patterns(
    'myapp.views',

    # (略)
    url(r'^sub_name/download/$', 'another_download', name='another_download'),
)

templates/myapp/sub_name_list.html

<form method="post" action="{% url myapp:another_download %}">
  <input type="submit" name="csv_download" value="CSV Download" />                                                                                                                                                                                                
</form>

程序运行的时候提示:

Caught NoReverseMatch while rendering: u'myapp' is not a registered namespace

为什么说“myapp”这个命名空间没有注册呢?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/141
文章 [ 2 ]  |  最新文章 12 年前
ithelloworld
Reply   •   1 楼
ithelloworld    12 年前

@feature 谢谢!解决了!

爱情的枪
Reply   •   2 楼
爱情的枪    12 年前

你要在你的主urls.py里写上

 url (r'^myapp/', include('myapp.urls', namespace='myapp')),

你可以看看 http://stackoverflow.com/questions/14867728/django-error-noreversematch-while-i-rendering 这里吧