4👍
You can do:
return HttpResponseRedirect(request.path_info)
You can also read about how Request/Response works in Django but also about the request.path_info
in the docs
3👍
You can use request.path to find the current url of the request and then redirect.
from django.shortcuts import redirect
return redirect(request.path)
0👍
from django.http import HttpResponseRedirect
return HttpResponseRedirect(request.path_info)
0👍
Use "request.path" to get the current url as shown below:
# "views.py"
from django.shortcuts import redirect
def my_view(request):
return redirect(request.path) # Here
Or, use "request.path_info" to get the current url as shown below:
# "views.py"
from django.shortcuts import redirect
def my_view(request):
return redirect(request.path_info) # Here
- [Django]-What does 'serializer.initial_data' mean?
- [Django]-Crispy-forms InlineRadios don't show my model state
- [Django]-How can I use django.auth.views.login?
Source:stackexchange.com