10👍
✅
return HttpResponseRedirect(reverse('getting_started_info', kwargs={'location': location}))
12👍
Remember that redirect()
isn’t doing a direct call to your view, it’s actually sending the client’s browser a 302 Found
status (301 Moved Permanently
if you use permanent=True
) with an instruction to redirect to a different URL. In this case, that URL is one that resolves to the getting_started_info
view.
I believe that for this to work, there must exist a urlconf which maps to getting_started_view
and which uses its location
positional argument. This will most likely occur through named groups.
From the django 1.8 docs entry on redirect()
:
The arguments could be:
- A model: the model’s get_absolute_url() function will be called.
- A view name, possibly with arguments: urlresolvers.reverse will be used to reverse-resolve the name.
- An absolute or relative URL, which will be used as-is for the redirect location.
- Django: use render_to_response and set cookie
- Where is Pip3 Installing Modules?
- Django: datetime filter by date ignoring time
- Custom label on ModelChoiceField form field
Source:stackexchange.com