How to execute a method from Class Based Views on the opening page of Django?

Good day, trying to deal with CBV.
Want the function test_http_response worked out as soon as the request url, but that it is not working. Tell me how, please.

class PostDetailView(DetailView):
 model = Post
 def test_http_response(self, request, pk):
 HttpResponse("test response")
 print("test")
April 7th 20 at 15:27
1 answer
April 7th 20 at 15:29
Solution
class PostDetailView(DetailView):
 model = Post
 def dispatch(self, request, *args, **kwargs):
 resp = HttpResponse("test response")
print("test")
 return resp

Find more questions by tags Django