Answer the question
In order to leave comments, you need to log in
How to execute a method from Class Based Views on opening a Django page?
Good afternoon, I'm trying to deal with CBV.
I want the test_http_response function to be processed as soon as a request for the URL is made, but it doesn’t work for some reason. Tell me the right way, please.
class PostDetailView(DetailView):
model = Post
def test_http_response(self, request, pk):
HttpResponse("test response")
print("test")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question