1👍
✅
The whole point of using Ajax is that it overrides the browser navigation handling. If you want your Ajax to redirect, you need to do it in js – or, don’t use Ajax at all.
0👍
redirect either needs the relative or absolute url that you need to redirect to.
You need to use django reverse url resolver
from django.core.urlresolvers import reverse
def func1(request):
if not request.user.is_authenticated():
return render(request, 'login/login/login.html')
else:
if request.method == "POST":
return redirect(reverse('base:func2'))
return render(request, 'base/home/index.html')
- Django rejects certain Slug URLs but accepts others
- In template 'a href' adds domain to the url, making url like my_domain/my_url. How to avoid this behaviour?
Source:stackexchange.com