Answer the question
In order to leave comments, you need to log in
How to make a warning page before deleting a post?
Good afternoon. Let's agree that we have a website where you can create topics and make notes on these topics. There is a function to delete an entry (indents are observed):
def remove_entry(request, entry_id):
"""Удаляет конкретную запись"""
entry = Entry.objects.get(id=entry_id)
topic = entry.topic
if topic.owner != request.user:
raise Http404
entry.delete()
return redirect('learning_logs:topic', topic_id=topic.id)
Answer the question
In order to leave comments, you need to log in
Well, you need to do the following, on the "Delete Entry" button you make a link to the delete page. On the delete page, you add a form. And the form calls a POST request to the same page. In the same place you can add a link "Return to the record".
The logic is this, if there is a GET request on this shame, then you display a deletion confirmation, that is, a form. And if the request is POST, then you are already performing the deletion itself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question