Got an error in Django view : "NoReverseMatch at /view/"

Here are my urls :

root urls.py

urlpatterns = [ path('admin/', admin.site.urls), path('',include('store.urls')), 

]

url.py

    urlpatterns = [     path('',views.store,name='store'),     path('cart/',views.cart,name='cart'),     path('checkout/',views.checkout,name='checkout'),     path('update_item/',views.updateItem,name='update-item'),     path('process_order/',views.processOrder,name='process-order'),     path('view/<int:pk>/',views.view,name='view-detail'), ] 

Here is the code for the view :

views.py

    def view(request,pk):         product = Product.objects.get(id=pk)         return render(request,'store/view.html',{'product':product} ) 

Here is my template : template

    <a class="btn btn-outline-success" href="{% url 'view-detail' product.id%}">View</a>  

This output error :

NoReverseMatch at /view/1/ Reverse for ‘store’ with arguments ‘(1,)’ not found. 1 pattern(s) tried: [‘$’]

How to resolve this error?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.