from django.urls import path
from .views *
urlpaterns=[
path('product/<int:pk>/', product_detail, name='product_detail'),
]
#urls.py
#views.py
def product_detail(request,pk):
products=product.objects.filter(pk=pk)
title_spisok=spisok.objects.filter(product=pk)
punkt=punkt_of_spisok.objects.filter(spisok=pk)
return render(request,'product_detail.html', {'products':products,
'title_product':title_spisok,
'punkts':punkt
})
#models.py
class punkt_of_spisok(models.Model):
punkt=models.CharField(max_length=255, verbose_name='Пукт')
spisok=models.ForeignKey('spisok',on_delete=models.CASCADE)
class spisok(models.Model):
title=models.CharField(max_length=255, verbose_name='Заголовок списка')
product=models.ForeignKey('product', verbose_name='Продукт', on_delete=models.CASCADE)