I am building my first website. But instead of the page being products/15
(where 15 is the product id), I want it to show the description of the product. How can I achieve that?
Here are my models.py:
class Product(models.Model):
name = models.CharField(max_length=100)
category = models.CharField(max_length=100)
description = models.TextField()
def __str__(self):
return self.name
views.py:
def product(request, id):
return render(request, 'product.html', {})
urls.py:
urlpatterns = [
path('products/<id>/', post, name='sub-detail'),
]
Thanks in advance for the help!