决定与django-allauth连接后去哪里 [英] decide where to go to after connecting with django-allauth

查看:163
本文介绍了决定与django-allauth连接后去哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用django-allauth连接到社交应用的帐户后,用户被重定向到 accounts / social / connections 。如何更改此行为?

After connecting an account with a social app using django-allauth the user is redirected to accounts/social/connections. How can I change this behavior?

推荐答案

如果用户在现有(本地)帐户中添加了更多的社交帐户,那么最合乎逻辑的默认将确实是重定向到社交帐户连接管理屏幕。

If the user is adding more social accounts to his existing (local) account, then the most logical default would be indeed to redirect to the social account connections management screen.

但是,您可以通过传递下一个参数轻松覆盖默认值。看看这里:

However, you can easily override the default by passing along a next parameter. Have a look here:

https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/helpers.py#L125

您会看到下一个参数已被检查,退回到默认(连接)。

You'll see that the next parameter is checked, falling back to the default (connections).

因此,要更改默认行为,只需传递下一个参数:

So, to change the default behavior, simply pass along a next parameter:

<a href="{% provider_login_url "openid" openid="https://www.google.com/accounts/o8/id" next="/success/url/" %}">Google</a>

如果您使用默认模板,则必须在此处添加下一个网址:

If you are using the default templates you'll have to add next urls here:

https://github.com/pennersr/django-allauth/blob/master/allauth/templates/socialaccount/connections.html#L53

这篇关于决定与django-allauth连接后去哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆