[collector view] rudimentary implementation of list and detail view

This commit is contained in:
bronsen 2025-03-12 23:52:18 +01:00
parent d6ff246804
commit 6214610edc
4 changed files with 36 additions and 3 deletions

View file

@ -1,6 +1,17 @@
from django.http import HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse
from .models import Teil
def index(request) -> HttpResponse:
return HttpResponse("hello tutorial")
def index(request: HttpRequest) -> HttpResponse:
teile_list = Teil.objects.order_by("-modified")[:10]
context = {
"teile_list": teile_list,
}
return render(request, "collector/index.html", context)
def detail(request: HttpRequest, teil_id) -> HttpResponse:
teil = get_object_or_404(Teil, pk=teil_id)
return render(request, "collector/detail.html", {"teil": teil})