From cf64c5525ea37fb34d0a5113616e09641b76933b Mon Sep 17 00:00:00 2001 From: William Date: Fri, 8 Sep 2023 09:55:02 +0200 Subject: [PATCH] updated views and individual stock templates --- chemie/stock/templates/stock/individualstock.html | 13 ++++++++++++- chemie/stock/views.py | 9 +++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/chemie/stock/templates/stock/individualstock.html b/chemie/stock/templates/stock/individualstock.html index b070e6b0..bceb3ae1 100644 --- a/chemie/stock/templates/stock/individualstock.html +++ b/chemie/stock/templates/stock/individualstock.html @@ -14,6 +14,17 @@ {{name}} -

Beskrivelse: {{desc}}

+
+
+

Beskrivelse: {{desc}}

+

Value: {{value}}

+
+ +
+ + +
+ +
{% endblock content %} \ No newline at end of file diff --git a/chemie/stock/views.py b/chemie/stock/views.py index 0b9306fb..8a3974bf 100644 --- a/chemie/stock/views.py +++ b/chemie/stock/views.py @@ -26,17 +26,18 @@ def index(request): def stock_index(request, id): - stocktypes = Stocktype.objects.all() - stocktype = stocktypes.get(id = id) + stocktype = get_object_or_404(Stocktype, id = id) name = stocktype.name desc = stocktype.desc + value = stocktype.history_set.order_by("-date").first().value + #volume - #value context = { "name":name, - "desc":desc + "desc":desc, + "value":value } return render(request, "stock/individualstock.html", context)