Django反向解析错误的URL

时间:2014-05-13 18:40:18

标签: django

使用Django 1.6,当有Http404时,为什么网址会解析为cci_update而不是manual_entry_cci

    url(r'^cci/(?P<pk>\d+)/$', views.CCiDetail.as_view(), name='cci_detail'),
    url(r'^cci/(?P<pk>\d+)/update/$', views.CCiLimitUpdateView.as_view(), name='cci_update'),
    url(r'^cci/search/$', views.CCiSearch.as_view(), name='cci_search'),
    url(r'^cci/manual_enter/(?P<cci_entry>\d+)/$', views.ManualDdiEnter.as_view(), 
        name='manual_entry_cci'),



class CCiDetail(LoginRequiredMixin, DetailView):
    model = CCi

    def get_object(self, queryset=None):
        slug =  self.kwargs['pk']
        try:
            cci = super(CCiDetail, self).get_object(queryset)
            return cci
        except Http404:
            return HttpResponseRedirect(reverse('manual_entry_cci',
                kwargs={'cci_entry': slug}))







Request Method: GET
Request URL:    http://10.14.44.19:8000/cci/454/
Django Version: 1.6.4
Exception Type: NoReverseMatch
Exception Value:        
Reverse for 'cci_update' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['cci/(?P<pk>\\d+)/update/$']

1 个答案:

答案 0 :(得分:1)

这很奇怪:

 1 pattern(s) tried: ['cci/(?P<pk>\\d+)/update/$']

我猜你给我们展示的你的网址配置不是用的,而是另一个。我想django会加载旧的url配置。