Verified Commit 33902cb8 authored by Jonathan Weth's avatar Jonathan Weth

Use get_object_or_404 for delete view to prevent server errors

parent 604bf2bc
......@@ -4,7 +4,7 @@ import time
from django.contrib.auth.decorators import login_required, permission_required
from django.http import FileResponse
from django.shortcuts import render, redirect
from django.shortcuts import render, redirect, get_object_or_404
from django.utils import timezone
from .models import Menu
......@@ -34,7 +34,8 @@ def upload(request):
@login_required
@permission_required("mensa.add_menu")
def delete(request, id):
Menu.objects.get(id=id).delete()
menu = get_object_or_404(Menu, pk=id)
menu.delete()
messages.success(request, _("The menu was deleted successfully."))
return redirect("menu_index")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment