I have a messaging app with a url for each post:
url(r'^post/(?P<id>\w+)/$', 'single_post', name='single_post'),
In each post I have comments. I would like to be able to delete every comment from the mail page and return to the message I was in.
I have the following url to delete comments:
url(r'^comment/(?P<pk>\d+)/delete/$', CommentDelete.as_view(), name='comment_delete'),
And I know from previous studies that I need to override get_success_url, but I'm not sure how to refer to the identifier of the message I was just on. I think I need to use kwargs, but I donβt know how to do it. I have it now, but it does not work ...
class CommentDelete(PermissionMixin, DeleteView): model = Comment def get_success_url(self): return reverse_lazy( 'single_post', kwargs = {'post.id': self.kwargs.get('post.id', None)},)
Ideas appreciated!
source share