-
-
Save aliceridgway/06b6c9f7176ffbfda8f23b52d06e4802 to your computer and use it in GitHub Desktop.
delete post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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