Answer the question
In order to leave comments, you need to log in
How to add post method to DetailView?
There is a view with the DetailView class, if you send a form with the post method to it, then the HTTP error ERROR 405 , as far as I understand, in the DetailView class there is no post method in the documentation, I read about http_method_names and defined it
, the same error I don’t want to use the get method for filters, since the url string becomes
Is it possible to somehow define the post method in this view with the DetailView class ?http_method_names = ['get', 'post']
Answer the question
In order to leave comments, you need to log in
in the first answer they correctly said that you need to implement the post method on your view inherited from DetailView, somewhere like this:
class BlogDetailView(DetailView):
template_name= 'blog-info.html'
model = Blog
def post(self, request, *args, **kwargs):
# тут ваши действия
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question