Reputation: 393
I got this error using django 2.2 here are my codes
app_name = 'products'
urlpatterns = [
url(r'^$', product_list, name='product-list'),
url(r'^(?P<slug>.*)/$',single, name="single_product"),
url(r'^category/(?P<slug>.*)/$',category_single,name="category")
]
def get_absolute_url(self,):
return HttpResponseRedirect(reverse('single_product',args=[self.slug]))
<h3>{{ product }}</h3>
<p>{{ product.description }}</p>
<p>{{ product.get_price }}</p>
<p>
<a href ="{% url 'products:single_product' %}" class = "btn btn-primary" role = "button">
View Product
</a>
Upvotes: 3
Views: 6627
Reputation: 27523
you are not passing the slug in the url but have given a parameter to your pattern.
so change the html
<a href ="{% url 'products:single_product' product.slug %}" class = "btn btn-primary" role = "button">
View Product
</a>
Upvotes: 7