0
我被困在这件事上。django - NoReverseMatch at/url/- 奇怪的问题
urls.py
print 'test before'
urlpatterns = patterns('horoscopes.views',
url(r'^$', 'index', name="index"),
url(r'^(?P<sign_name>\w+)/(?P<sign_num>\d+)/$', 'horoscope_detail', name="horoscope_detail"),
)
print 'test after'
HTML
<a href="{% trans 'Capricorn' as capri %}{% url 'horoscope_detail' capri 0 %}">
Capri
</a>
views.py
def horoscope_detail(request, sign_name, sign_num):
# ...
我只是不断收到:
反向的“^ h oroscope_detail'with arguments'(u'Capricorn',0)'和 找不到关键字参数'{}'。 0模式尝试:[]
"test before"
和"test after"
正在打印。
我在做什么错在这里?正则表达式似乎是正确的,但真正令人困惑..
可能是一个愚蠢的问题,但项目匹配'摩羯座'和0 *绝对*存在数据库中? (我假设它是来自其他代码的测试数据库) – 2014-10-06 10:16:13
@cms_mgr此错误与db无关。这条路线甚至不会通过urls.py传递,这是现在的问题。 – doniyor 2014-10-06 10:18:00
你有没有试过这样的:'{%url'horoscope_detail'sign_name ='capri'sign_num = 0%}'? – andrean 2014-10-06 10:19:59