feat: added seo template and prioduct.slug

This commit is contained in:
2024-11-22 21:40:27 +01:00
parent 2d7119c6c1
commit b057b70a31
13 changed files with 644 additions and 33 deletions
+9 -1
View File
@@ -9,6 +9,11 @@ from shop.models import Product
class IndexView(TemplateView):
template_name = "shop/index.html"
def get_context_data(self, **kwargs):
return {
"title": "Shoppy",
}
class ListProducts(TemplateView, FilteredQuerysetMixin, PaginatedQuerysetMixin):
template_name = "shop/list_products.html"
@@ -27,11 +32,14 @@ class ListProducts(TemplateView, FilteredQuerysetMixin, PaginatedQuerysetMixin):
class ProductDetail(TemplateView):
template_name = "shop/product_detail.html"
def get_context_data(self, pk, **kwargs):
def get_context_data(self, pk, slug, **kwargs):
product = get_object_or_404(Product, pk=pk)
return {
"product": product,
"title": product.name,
"description": product.description,
"image": product.images.first(),
}