微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Django allauth 重定向到上一页

如何解决Django allauth 重定向到上一页

除了 django auth 之外,我还使用 Django allauth 来登录我的 web 应用程序中的用户。 我想在登录或使用allauth登录时将用户返回到当前页面

我已经浏览了一些答案,但在我的情况下没有任何效果

请看下面我的代码

#settings.py
ACCOUNT_ADAPTER = 'kvizmaster.adapter.MyAccountAdapter'

#adaper.py
from django.http import HttpResponseRedirect
from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter

class MyAccountAdapter(DefaultAccountAdapter):
    
    def get_login_redirect_url(self,request):
        print("in code")
        redirect_to = request.GET.get('next','')
        print(redirect_to)
        return HttpResponseRedirect(redirect_to) 

登录网址

<a title="Google" class="socialaccount_provider google" style="text-decoration:none;" href="/accounts/google/login/?process=login?next={{request.GET.next}}">Sign in with Google</a>

形成下一个变量

<input type="" name="next" value="{{ request.GET.next }}"/>

登录 url 分配了正确的 href 并且下一个变量适用于表单。但是,我无法访问adapter.py 中的“next”。请提出建议。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。