I have the following scenery. In the first page there are type of products, when choose specific type it sends to the page of products of the specific type, then when I choose the product it should send me to the page of the product where there is full information about the product. But I can't access the last product page. How I should fix this? My code:
views.py:
def products_fizlitso(request):
fizlitso_product = InsuranceProducts.objects.filter(product_type="Физическое
Лицо")
context = {'fizlitso_product': fizlitso_product}
return render(request, 'insurance_products/fizlitso/fizlitso.html', context)
def fizlitso_type(request, type_id):
product_type = get_object_or_404(InsuranceProducts, id=type_id)
context = {'product_type': product_type}
return render(request, 'insurance_products/fizlitso/fizlitso_type.html',
context)
def product_page(request, product_id):
product = get_object_or_404(ProductType, id=product_id)
context = {'product': product}
return render(request, 'insurance_products/fizlitso/product.html', context)
here is the urls.py:
# ******************************************************************
path('fizlitso/', views.products_fizlitso, name='product_fizlitso'),
# ******************************************************************
# ******************************************************************
path('fizlitso/product_type<int:type_id>', views.fizlitso_type, name='fizlitso_type'),
# ******************************************************************
# ******************************************************************
path('fizlitso/product_type<int:type_id>/product<int:product_id>', views.product_page, name='product_page'),
# ******************************************************************
and here is the django part of the template which holds all the product types:
{% for product in fizlitso_product %}
<div class="btmspace-80">
<h3>{{ product.product_area }}</h3>
<img class="imgr borderedbox inspace-5" src="{% static 'img/imgr.gif' %}" alt="">
<p>
{{ product.product_description }}
</p>
<p>
Подробно вы можете узнать <a href="{% url 'main:fizlitso_type' product.id %}">здесь</a></a>
</p>
</div>
{% endfor %}
And here the django part of the template which holds all the products of the specific type:
{% for product in product_type.producttype_set.all %}
<div class="btmspace-80">
<h3>{{ product.title }}</h3>
<img class="imgr borderedbox inspace-5" src="{% static 'img/imgr.gif' %}" alt="">
<p>
{{ product.description }}
</p>
line 84 <p>
Подробно вы можете узнать <a href="{% url 'main:product_page' product.id %}">здесь</a></a>
</p>
</div>
{% endfor %}
And here is the page about the specific product chosen from above page:
<div class="btmspace-80">
<h3>{{ product.title }}</h3>
<img class="imgr borderedbox inspace-5" src="{% static 'img/imgr.gif' %}" alt="">
<p>
{{ product.description }}
</p>
</div>
And this one is the error:
NoReverseMatch at /fizlitso/product_type1
Reverse for 'product_page' with arguments '('',)' not found. 1 pattern(s) tried: ['fizlitso\/product_type(?P[0-9]+)\/product(?P[0-9]+)$']
C:\Users\Lenovo 101\PycharmProjects\uzagro_3\main\templates\insurance_products\fizlitso\fizlitso_type.html, error at line 84
your url name product_page have two parameters:type_id,product_id
path('fizlitso/product_type<int:type_id>/product<int:product_id>', views.product_page, name='product_page')
you give one?
<a href="{% url 'main:product_page' product.id %}">