Reputation:
I have created a view that accepts 3 arguments but I get the following error in the homepage.
Reverse for 'application-detail' with arguments '(5,)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/devices/(?P[^/]+)$']
urlpatterns = [
path('',views.MapView,name='home'),
path('map/',views.MapView,name='map'),
path('<int:application_id>/devices/<cat>', views.ApplicationDetail, name='application-detail'),
]
View:
def ApplicationDetail(request, application_id,cat):
device = Device.objects.all().filter(category=cat)
data = serializers.serialize('json', device)
return HttpResponse(data, content_type='application/json')
Upvotes: 0
Views: 173
Reputation: 2222
You are most likely calling the reverse
function somewhere in your code like:
reverse('application-detail', args=(5))
However, the path
for reverse
takes two arguments, an int
(application_id
) and a string
(cat
) and thus, when calling reverse, you must also provide the string
, e.g.:
reverse('application-detail', args=(5, 'super cat`))
Upvotes: 1