Getting NoReverseMatch error when trying to redirect user after form upload

I am getting the error NoReverseMatch in Django when I try to redirect the user to a new url after processing a form upload and succesfully saving the form. Here is my

def profile(request):
    if request.method == 'POST':
        profile_form = UpdateProfileForm(request.POST, request.FILES, instance=request.user.profile)
        files = request.FILES.getlist('resume')
        resumes_data = []
        if profile_form.is_valid():
            for file in files:
                    # saving the file
                    resume = profile_form.cleaned_data['resume']

                    parser = ResumeParser(file.temporary_file_path())
                    data = parser.get_extracted_data()
           = data.get('name')
                        = data.get('email')
                    profile_form.instance.mobile_number      = data.get('mobile_number')
                    if data.get('degree') is not None:
                    = ', '.join(data.get('degree'))
                    = None
                        profile_form.instance.company_names      = data.get('company_names')
                        profile_form.instance.college_name       = data.get('college_name')
                        profile_form.instance.designation        = data.get('designation')
                        profile_form.instance.total_experience   = data.get('total_experience')
                    if data.get('skills') is not None:
                        profile_form.instance.skills         = ', '.join(data.get('skills'))
                        profile_form.instance.skills         = None

                    if data.get('experience') is not None:
                        profile_form.instance.experience     = ', '.join(data.get('experience'))
                        profile_form.instance.experience     = None
                    return redirect('users-profile')
                except IntegrityError:
                    messages.warning(request, 'Duplicate resume found')
                    return redirect('users-profile')
        messages.success(request, 'Your profile is updated successfully')
        # return redirect(reverse('userprofile', kwargs={"id": request.user}))
        return redirect('userprofile')
        profile_form = UpdateProfileForm(instance=request.user.profile)

    return render(request, 'user/resumeprofile.html', {'profile_form': profile_form})

def myprofile(request, user_id):
    profile = Profile.objects.get(id=user_id)
    context = {'profile':profile}
    return render(request, 'user/profile.html', context)

And here is my

urlpatterns = [
    path('', jobs_views.home, name='home'),   #this is home function inside the in the jobs folder
    path('contact',, name='contact'),
    # path('jobs/', jobs_views.job_list, name='job-list'),
    path('jobs/<slug:slug>', jobs_views.job_detail, name='job_detail'), #slug will help us identify the specific instance of job

    path('jobs-search/', jobs_views.job_search, name='job_search'),
    path('profile/', jobs_views.profile, name='users-profile'),
    path('userprofile/<int:user_id>',jobs_views.myprofile, name='userprofile')


The error occurs when I redirect the user to userprofile but I dont get any error when I redirect them to users-profile. Attached is a screenshot of the error message displayed. The Screenshot of the error

Any help will be highly appreciated. Thanks in advance.

You can go around it by just taking the user id from the request since they are required to be logged in.

In your paths, change the path userprofile to :

path('userprofile/',jobs_views.myprofile, name='userprofile') # remove id parameter

Then in your myprofile view, change to:

    def myprofile(request):
        user_id =
        profile = Profile.objects.get(id=user_id)
        context = {'profile':profile}
        return render(request, 'user/profile.html', context)
Back to Top