Ошибка:
KeyError at /goods/good/15/delete/
'good_id'
Код:
views.py
class GoodDelete(DeleteView, GoodEditMixin, GoodEditView):
model = Good
template_name = 'good_delete.html'
pk_url_kwarg = 'good_id'
# fields = ['name', 'description', 'price', 'in_stock', 'category']
def post(self, request, *args, **kwargs):
self.success_url = reverse('index', kwargs={'cat_id': Good.objects.get(pk=kwargs['good_id']).category.id})
return super(GoodDelete, self).post(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(GoodDelete, self).get_context_data(**kwargs)
context['good'] = Good.objects.get(pk=kwargs['good_id'])
return context
urls.py
urlpatterns = [
url(r'^good/(?P<good_id>\d+)/$', GoodDetailView.as_view(), name='good'),
url(r'^(?P<cat_id>\d+)/add/$', GoodCreate.as_view(), name='good_add'),
url(r'^good/(?P<good_id>\d+)/edit/$', GoodUpdate.as_view(), name='good_edit'),
url(r'^good/(?P<good_id>\d+)/delete/$', GoodDelete.as_view(), name='good_delete')
]
good_id
не передается в контекст, судя по ошибке. Вообще тяжело помочь вопросу оформленному таким образом