简体   繁体   中英

Redirect to ?next=/accounts/social/connections/ in django-allauth

I am trying to redirect at /account/profile but instead i am getting redirected at ?next=/accounts/social/connections/ while using django-allauth.

Any ideas? My settings.py i have set LOGIN_REDIRECT_URL = '/' and on my twitter app the callback url is set to http://127.0.0.1:8000/accounts/twitter/login/callback/ .

I have also tried with creating adapter:

from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter

class MyAccountAdapter(DefaultAccountAdapter):

    def get_login_redirect_url(self, request):
        path = "/accounts/{username}/"
        return path.format(username=request.user.username)

and inside settings.py :

ACCOUNT_ADAPTER = 'sleep.adapter.MyAccountAdapter'

but again its redirected me to:

localhost:8000/accounts/login/?next=/accounts/social/connections/ .

A couple things that might be going on here:

1) Social media logins use the class specified by SOCIALACCOUNT_ADAPTER (not ACCOUNT_ADAPTER ) in settings.py . So with your current settings.py , when you connect to Twitter it will not call sleep.adapter.MyAccountAdapter.get_login_redirect_url() .

2) /accounts/social/connections/ is the default URL for the view named socialaccount_connections . It is likely that you are trying to connect your Twitter account instead of login via Twitter.

Make sure the provider_login_url tag in your template is not using the process="connect" argument.

{% load socialaccount %}
{% providers_media_js %}
<a href="{% provider_login_url "facebook" process="login" method="js_sdk" %}">Login with your Facebook Account</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM