DEV Community

Cover image for Facing Error while accessing customer name link using id.
Shailesh Waghole
Shailesh Waghole

Posted on

Facing Error while accessing customer name link using id.

When I click on Customer name which has id=1. Then "customer() missing 1 required positional argument: 'id' this error has occurred.

This is my customer view:
'''
def customer(request,id):
customer=Customer.objects.get(pk=id)
order=customer.order_set.all()
return render(request,'accounts/customer.html',{'customer':customer, 'order':order})
'''

This is my URL.py:

'''

from django.urls import path
from . import views

urlpatterns = [
path('',views.home,name='home'),
path('customer/',views.customer,name='customer'),
path('product/int:id/',views.product,name='product'),

]
'''

Top comments (4)

Collapse
 
michaeltharrington profile image
Michael Tharrington

Hey there!

Just wanted to let you know that the #help tag would work well here if you're asking a question.

Collapse
 
shailesh6363 profile image
Shailesh Waghole

Thanks for reply.
I have added help tag.

Collapse
 
shailesh6363 profile image
Shailesh Waghole

You mean remove the I'd ??

 
shailesh6363 profile image
Shailesh Waghole

after removing id tag following error occurred:

"customer() missing 1 required positional argument: 'id'"