1👍
Yes, a redirect can be used in the same view function. Here is an example
def index(request):
ctx = {}
# one in 3 chance to redirect
if random.randint(0, 2) > 1:
return redirect ('/')
return render(request, 'type/main.html', ctx)
Django redirect method returns a header[302] to the client, requesting a load to a new page. If you don’t see the browswr refresh, it’s because the browser didn’t complete the request.
Source:stackexchange.com