I’m creating a DeleteView which needs to access to kwargs outside of the methods, like this:
class DeletePost(DeleteView):
"""
Delete a post. Post deletion is only reserved to space
administrators or site admins.
"""
context_object_name = "get_place"
success_url = '/spaces/' + kwargs['space_name']
def get_object(self):
return get_object_or_404(Post, pk=self.kwargs['post_id'])
But apparently, arguments and keyword arguments can’t be used outside the methods. I also tried to stablish the success_url inside the get method, but django does not recognize it. What can I do to obtain the space_name parameter? I’m trying to avoid overriding the view core methods like dispatch() and such.
Override the
get_success_url()method.