2014-05-13 2 views
0

Django 1.6을 사용하면 Http404가있을 때 URL이 manual_entry_cci 대신 cci_update으로 어떻게 해결됩니까?Django가 잘못된 URL로 역전 처리합니다.

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/$'] 
+0

나는 이것에 대해 확실하지 않지만 get_object 메소드에 대해 HttpResponse 객체를 반환 할 수 있습니까? – toad013

답변

1

이 이상하다 :

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

나는 당신의 URL 당신이 우리를 사용하지 않는 표시 설정,하지만 다른 일을 생각한다. 난 django 오래된 URL 구성을로드하는 것 같아요.

+0

아니요. 왜냐하면 인수'cci_entry'가 불일치하기 때문에 실패로 인해'manual_entry_cci'에 충돌하기 때문입니다. – dman