Is there any way to redirect to a view from a separate view with arguments for that view function in Django?

I cannot for the life of me find a way to redirect to another view with arguments for that view in Django. I've tried the django.shortcuts redirect method, but that doesn't seem to work (it seems to want to take patterns for the url pattern and not the view function. The HttpResponseRedirect function obviously doesn't work because that function just redirects to another url. What other options are there?

Seems you want to give use redirect and want to give a parameter thats so easy you can do that

x.order_total= total+shipping_total
        return redirect(f'/order/payment/{order_number}')

here i have pasted just a snippet of my one view which is doing that you can insert the parameter using f outside the string if you have matching url it will work fine

You can redirect to other view with parameter(s) using reverse that doesn't use hard coded url instead the name of url infact redirect uses that internally

def view_one(request):
    return redirect('view_two', arg=arg)

By default redirect will do temporary redirect for perminant redirect you have to specify it as to know the difference between the two take a look here

You can use the reverse function to fill your URL pattern You can import the reverse function with the following line:

from django.core.urlresolvers import reverse

If you have URLs like this you can use reverse:

path('project/<str:project_id>/', name='edit_project'),


redirect(reverse('edit_project', kwargs={'project_id':4}))


redirect(reverse('app_name:edit_project', kwargs={'project_id':4}))

Doc here