1👍
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
x.save()
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
0👍
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
- [Answered ]-Does the CSRF info change when logging in via ajax request?
- [Answered ]-Django template is not showing python variables anymore
0👍
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:
url(r'^project/(?P<project_id>\d+)/$','user_profile.views.EditProject',name='edit_project'),
path('project/<str:project_id>/', name='edit_project'),
usage:
redirect(reverse('edit_project', kwargs={'project_id':4}))
or:
redirect(reverse('app_name:edit_project', kwargs={'project_id':4}))
Doc here
- [Answered ]-Django Python: Install multiple versions of the same package within a virtualenv
- [Answered ]-Line 158, in get_app_config return self.app_configs[app_label] KeyError: 'account'