1

I have this in my urls.py:

urlpatterns = patterns('',
                       url(r'^ding/', include('ding.urls', namespace='ding', app_name='ding')),

And this in my ding/urls.py:

urlpatterns = patterns('',
                       url(r'^$', views.sign_in, name='sign_in'),
                       url(r'^connect/$', views.connect, name='connect'),
                       url(r'^disconnect/$', views.disconnect, name='disconnect'),
                       #url(r'^disconnect/sign_in/$', RedirectView.as_view(url=reverse('sign_in')), name="disconnect_sign_in"),
                       url(r'^search$', views.search, name='search'),
                       url(r'^parsed_query/(?P<query>.+)/(?P<scroll_num>(\-|)\d+)/$', views.get_search_results, name='get_search_results'),
                       url(r'^parsed_query/', views.parsed_query, name='parsed_query'),
                       url(r'^parsed_query_redirect/', views.parsed_query_redirect, name='parsed_query_redirect'),
)

Calling any of the following:

print reverse('sign_in', current_app='ding')
print reverse('connect', current_app='ding')
print reverse('disconnect', current_app='ding')
...

results in a NoReverseMatch error.

Any suggestions?

4

1 回答 1

2
reverse('ding:sign_in')

参考:https ://docs.djangoproject.com/en/1.6/topics/http/urls/#topics-http-reversing-url-namespaces

确保您知道应用程序命名空间和实例命名空间之间的区别: https
://docs.djangoproject.com/en/1.6/topics/http/urls/#url-namespaces 我发现很少需要两者(但当然有有很多用例)。

于 2013-11-10T16:48:29.007 回答