diff --git a/collector/templates/collector/detail.html b/collector/templates/collector/detail.html new file mode 100644 index 0000000..0ef8e41 --- /dev/null +++ b/collector/templates/collector/detail.html @@ -0,0 +1,2 @@ +

{{ teil.name }}

+Last Changed: {{ teil.modified }} diff --git a/collector/templates/collector/index.html b/collector/templates/collector/index.html new file mode 100644 index 0000000..04e6280 --- /dev/null +++ b/collector/templates/collector/index.html @@ -0,0 +1,17 @@ +{% if teile_list %} + + + +{% else %} + +

Keine Teile da.

+ +{% endif %} diff --git a/collector/urls.py b/collector/urls.py index 5119061..c5ab785 100644 --- a/collector/urls.py +++ b/collector/urls.py @@ -2,6 +2,9 @@ from django.urls import path from . import views +app_name = "collector" + urlpatterns = [ path("", views.index, name="index"), + path("recorded//", views.detail, name="detail"), ] diff --git a/collector/views.py b/collector/views.py index ac03d0c..66052c4 100644 --- a/collector/views.py +++ b/collector/views.py @@ -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})