R
R
RabbitRun92021-09-24 16:07:28
Django
RabbitRun9, 2021-09-24 16:07:28

How to do delete via POST?

There is a function:

def delete(request, id):
    news = News.objects.get(id=id)
    news.delete()
    return redirect('index')


Task: to make the delete function through a POST request, and not through a GET.
How? Explain, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-09-24
@MEDIOFF

def post(request, id):
    news = News.objects.get(id=id)
    news.delete()
    return redirect('index')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question