Reputation: 413
I have this in urls.py
urlpatterns = [
path("product/<str:title>/<slug:pname>/<uuid:puid>",views.viewProduct),
]
But when I try to click on the url. I got this error.
The current path, product/amazon/home-secure-snake-shield-natural-snake-r/B0882NKXW7, didn't match any of these.
Here I just want the puid but to match the pattern of URL I added str:title and str:pname
I don't want the title and pname. But my URL patern is like this-
product/store_name/product_name_slug/product_id
Upvotes: 3
Views: 1299
Reputation: 477617
The B0882NKXW7
is not a valid format for a UUID [wiki]. Indeed, a UUID is typically represented as 16 octets. For example 2707820f-5182-407d-9c07-ff7845807d4c
is a UUID.
You can either define your own path converter [Django-doc] to accept your product id, or you can make use of str:
:
urlpatterns = [
path('product/<str:title>/<slug:pname>/<str:puid>', views.viewProduct),
]
Upvotes: 2
Reputation: 413
I replace the URL path
urlpatterns = [
path("product/<str:title>/<slug:pname>/<str:puid>",views.viewProduct),
]
Upvotes: 1