Skip to content

Instantly share code, notes, and snippets.

@aliceridgway
Created June 26, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliceridgway/06b6c9f7176ffbfda8f23b52d06e4802 to your computer and use it in GitHub Desktop.
Save aliceridgway/06b6c9f7176ffbfda8f23b52d06e4802 to your computer and use it in GitHub Desktop.
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