Answer the question
In order to leave comments, you need to log in
How to make django redirect on click?
The home page loads like this:
def main_page(request):
c = {}
c.update(csrf(request))
if not request.user.is_authenticated():
return HttpResponseRedirect('/accounts/login')
else:
return render_to_response('homeTemplate.html',c)
$('#goHome').click(function(){
//? ajax?
})
Answer the question
In order to leave comments, you need to log in
everything was easier
$('#goHome').click(function(){
window.location.replace('/');
})
url.py
(r'^$', main_page)
I will not go into details why this is necessary, although it is still interesting.
You can make a new controller (for example, ajaxLinkController - it will drive all such links), in which to pass #goHome, and in response to an ajax request, receive json with the desired url, which you can follow later.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question