[Answered ]-ValueError: Field 'id' expected a number but got 'gaming-peripherals'

1👍

If you filter with:

product = Product.objects.get(category=c_slug, slug=product_slug)

You will filter on the field the product ForeignKey is referring to. Since that is not specified, this is the primary key, and thus an AutoField.

You can filter with:

#                      filter on the slug ↓
product = Product.objects.get(category__slug=c_slug, slug=product_slug)

Leave a comment