diff --git a/NITAKUSHOP/__pycache__/__init__.cpython-310.pyc b/NITAKUSHOP/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..f33a742 Binary files /dev/null and b/NITAKUSHOP/__pycache__/__init__.cpython-310.pyc differ diff --git a/NITAKUSHOP/__pycache__/settings.cpython-310.pyc b/NITAKUSHOP/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..4a715de Binary files /dev/null and b/NITAKUSHOP/__pycache__/settings.cpython-310.pyc differ diff --git a/NITAKUSHOP/__pycache__/urls.cpython-310.pyc b/NITAKUSHOP/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..6d1e4d6 Binary files /dev/null and b/NITAKUSHOP/__pycache__/urls.cpython-310.pyc differ diff --git a/NITAKUSHOP/__pycache__/wsgi.cpython-310.pyc b/NITAKUSHOP/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..18b39cd Binary files /dev/null and b/NITAKUSHOP/__pycache__/wsgi.cpython-310.pyc differ diff --git a/main/__pycache__/__init__.cpython-310.pyc b/main/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..ae0eca0 Binary files /dev/null and b/main/__pycache__/__init__.cpython-310.pyc differ diff --git a/main/__pycache__/admin.cpython-310.pyc b/main/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..cbcb695 Binary files /dev/null and b/main/__pycache__/admin.cpython-310.pyc differ diff --git a/main/__pycache__/apps.cpython-310.pyc b/main/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..fef9760 Binary files /dev/null and b/main/__pycache__/apps.cpython-310.pyc differ diff --git a/main/__pycache__/models.cpython-310.pyc b/main/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..f146df5 Binary files /dev/null and b/main/__pycache__/models.cpython-310.pyc differ diff --git a/main/__pycache__/urls.cpython-310.pyc b/main/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..e617ac1 Binary files /dev/null and b/main/__pycache__/urls.cpython-310.pyc differ diff --git a/main/__pycache__/views.cpython-310.pyc b/main/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..363069a Binary files /dev/null and b/main/__pycache__/views.cpython-310.pyc differ diff --git a/main/migrations/__pycache__/0001_initial.cpython-310.pyc b/main/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000..dc0fad3 Binary files /dev/null and b/main/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/main/migrations/__pycache__/__init__.cpython-310.pyc b/main/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..5226f83 Binary files /dev/null and b/main/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/main/models.py b/main/models.py index 60d91a2..751a78c 100644 --- a/main/models.py +++ b/main/models.py @@ -18,6 +18,7 @@ class Category(models.Model): def get_absolute_url(self): return reverse('main:product_list_by_category', args=[self.slug]) + class Product(models.Model): category = models.ForeignKey(Category, related_name='products', diff --git a/main/templates/main/index.html b/main/templates/main/index.html index 9d14f05..8445494 100644 --- a/main/templates/main/index.html +++ b/main/templates/main/index.html @@ -51,18 +51,35 @@ -
-
-
- -
- - +
+
+
+ +
+ +
+
+ {% for product in products %} +
+
+ {{ +
+ +

{{ product.name }}

+
+

{{ product.description }}

+
+

{{ product.price }} $

+
+
+
+
+ {% endfor %} +
+
{#
#} {# #} diff --git a/main/urls.py b/main/urls.py index c07eacf..c2a12b0 100644 --- a/main/urls.py +++ b/main/urls.py @@ -6,7 +6,7 @@ app_name = 'main' urlpatterns = [ path('', views.index, name='index'), path('about/', views.about, name='about'), - path('', views.product_list, name='product_list'), + path('products/', views.product_list, name='product_list'), path('/', views.product_list, name='product_list_by_category'), path('//', views.product_detail, diff --git a/main/views.py b/main/views.py index d48df06..4222280 100644 --- a/main/views.py +++ b/main/views.py @@ -1,6 +1,7 @@ from django.shortcuts import render,get_object_or_404 from django.http import HttpResponse from .models import Category, Product + def index(request) -> HttpResponse: context : dict = { 'title':'Home', @@ -9,9 +10,13 @@ def index(request) -> HttpResponse: 'dict' : {'first':1}, 'is_authenticated':False } + products = Product.objects.all() + categories = Category.objects.all() + # Merge the two dictionaries into one + context.update({'products': products, 'categories': categories}) - return render(request, 'main/index.html',context) + return render(request, 'main/index.html', context) def about(request): context = {