如何从客户端手动调用django中的重定向函数

How to call redirect function manually in django from client?

本文关键字:django 重定向 函数 调用 客户端      更新时间:2023-09-26

我的django网站上的主页正在通过以下功能加载:

def homePage(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(){
    //execute homePage
})
$('#goHome').click(function(){
    window.location.replace('/');
})

url.py
(r'^$', main_page),