0

How do I properly reference the edit_product.html line to the Edit_Product in urls.py with 2 parameters?

I tried looking for examples but I couldn't find any.

This is the error I received:

Reverse for 'Edit_Product' with arguments '('eiffel',)' not found. 1 pattern(s) tried: ['shop/edit_product/(?P[-a-zA-Z0-9_]+)/(?P[-a-zA-Z0-9_]+)/$']

urls.py

from django.urls import path
from . import views

app_name='shop'

urlpatterns = [

    path('create_product/', views.CreateProduct, name='Create_Product'),
    path('edit_product/<slug:c_slug>/<slug:product_slug>/', views.EditProduct, name='Edit_Product'),
    path('', views.allProdCat, name='allProdCat'),
    path('<slug:c_slug>/', views.allProdCat, name='products_by_category'),
    path('<slug:c_slug>/<slug:product_slug>/', views.ProdCatDetail, name='ProdCatDetail'),
]

edit_product.html

<td><a href="{% url 'shop:Edit_Product' category.slug | product.slug %}">{{ product.name }}</a></td>
3
  • 1
    Don't you need two parameters here? Why do you write | in your {% url ... %}. Commented Jul 27, 2018 at 16:40
  • i tried to imitate this solution that was in django1.5: stackoverflow.com/questions/15181278/… Commented Jul 27, 2018 at 17:53
  • path('edit_product/<slug:c_slug>/<slug:product_slug>/', views.EditProduct, name='Edit_Product') and path('<slug:c_slug>/<slug:product_slug>/edit_product', views.EditProduct, name='Edit_Product'), would it still work the same if I type the following in the html: <a href="{% url 'shop:Edit_Product' category.slug product.slug %}"> Commented Jul 27, 2018 at 17:54

1 Answer 1

1

You don't need | just separate those with space

<a href="{% url 'shop:Edit_Product' category.slug product.slug %}">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.