[Answered ]-Correct way to redirect two views to one template with different url id Django

1👍

@user_login_required
def unassign_emp(request, eid):
   if request.method=='POST' and 'unassign_emp' in request.POST:
       unassign_emp = UsecaseAssign.objects.get(user_email=eid)
       unassign_emp.delete()
       messages.success(request, "User was unassigned with Usecase!")
   return redirect('usecase-details', kwargs={'ucid':unassign_emp.usecase_id})

You can pass the kwargs argument to redirect. More info: https://docs.djangoproject.com/en/4.1/topics/http/shortcuts/#django.shortcuts.redirect

Leave a comment