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/$']
나는 이것에 대해 확실하지 않지만 get_object 메소드에 대해 HttpResponse 객체를 반환 할 수 있습니까? – toad013