So first of all I admit I use CBV in django and I don't fully understand it.
I have a delete view implemented with CBV - I am trying to pass extra parameter uri (this parameter is a current URL from where delete have been called, this way after delete will get performed user will return to the same place from where he started.)
This is my url.py
url(r'^category/delete/(?P<pk>\d+)/(?P<uri>\S+)/$', item.views.CategoryDelete.as_view(),
name='category_delete',),
and this is my view.py I am inheriting delete view functionality
class CategoryDelete(DeleteView):
model = Category
success_url = reverse_lazy(uri)
def delete(self, uri, request, *args, **kwargs):
try:
return super(CategoryDelete, self).delete(
request, *args, **kwargs
)
except models.ProtectedError as e:
return HttpResponse(json.dumps(escape(e)))
Current code obviously gives me an error that uri is not defined. So the question is how to transfer additional parameter into the View class if I want to use success_url ? Or there is a better way?