From a85a288278dac03b9710885e9e24d307707dc152 Mon Sep 17 00:00:00 2001 From: Sharad Ahlawat Date: Tue, 10 Mar 2020 14:55:24 -0700 Subject: [PATCH] homepage --- products/templates/products/detail.html | 11 +++++++---- products/templates/products/home.html | 21 +++++++++++++++++++++ products/views.py | 3 ++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/products/templates/products/detail.html b/products/templates/products/detail.html index ad6e1c2..c10c6b8 100644 --- a/products/templates/products/detail.html +++ b/products/templates/products/detail.html @@ -13,16 +13,19 @@

{{ product.title }}

-
+
-
+

Hunted by: {{ product.hunter.username }}

@@ -31,7 +34,7 @@

{{ product.pubdate_pretty }}

-
+

{{ product.body }}

diff --git a/products/templates/products/home.html b/products/templates/products/home.html index c2402fa..277b33d 100644 --- a/products/templates/products/home.html +++ b/products/templates/products/home.html @@ -5,4 +5,25 @@

{% endif %} + {% for product in products.all %} +
+
+ +
+
+

{{ product.title }}

+

{{ product.summary }}

+
+ +
+
+ {% csrf_token %} + +
+ {% endfor %} {% endblock %} diff --git a/products/views.py b/products/views.py index ffd1cf3..a99c5f1 100644 --- a/products/views.py +++ b/products/views.py @@ -5,7 +5,8 @@ from django.utils import timezone def home(request): - return render(request, 'products/home.html') + products = Product.objects + return render(request, 'products/home.html', {'products': products}) @login_required()