Skip to content

Instantly share code, notes, and snippets.

@aliceridgway
Created Jun 26, 2022
Embed
What would you like to do?
delete post
def delete_post(request: HttpRequest, slug: str) -> HttpResponse:
post = get_object_or_404(Post, slug=slug)
if request.method == "POST":
post.delete()
return redirect("index")
context = {"post": post}
return render(request, "delete_post.html", context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment