From b28c42d9452c0c5ad9b157db2c95da1d9914fbdd Mon Sep 17 00:00:00 2001 From: Lukas Kucharczyk Date: Sun, 11 Aug 2024 20:21:44 +0200 Subject: [PATCH] delete platform --- games/platformviews.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/games/platformviews.py b/games/platformviews.py index d46c74f..6ccc1de 100644 --- a/games/platformviews.py +++ b/games/platformviews.py @@ -7,7 +7,6 @@ from django.shortcuts import get_object_or_404, redirect, render from django.template.loader import render_to_string from django.urls import reverse -from games.forms import PlatformForm from games.models import Platform from games.views import dateformat @@ -74,3 +73,8 @@ def list_platforms(request: HttpRequest) -> HttpResponse: return render(request, "list_purchases.html", context) +@login_required +def delete_platform(request: HttpRequest, platform_id: int) -> HttpResponse: + platform = get_object_or_404(Platform, id=platform_id) + platform.delete() + return redirect("list_platforms")