I have a first_view that takes id argument, And second_view that redirects to first_view after interpreting some code.
views.py:
def first_view(request, id):
#do something
return render(request, 'sometemplate.html')
def second_view(request, id):
#do something
return redirect('first_view', id=id)
when I try to go through second_view I get this error:
Reverse for 'first_view' not found.
urls.py:
path('first_view/<int:pnr_id>/', views.first_view, name='first_view'),
path('second_view/<int:pnr_id>/', views.second_view, name='second_view'),
I've tried these syntax for redirect too:
return redirect('first_view', id)
return redirect('first_view', args=[id])
return redirect('first_view', args=[id=id])
return redirect(first_view(id=id))
return redirect(first_view(id))
return redirect(first_view(request=request,id=id))
return redirect(first_view(request,id))
Nothing works! any support will be appreciated.