pip install django-allauth python INSTALLED_APPS = [ ... 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.weixin', ... ] AUTHENTICATION_BACKENDS = [ ... 'allauth.account.auth_backends.AuthenticationBackend' ... ] python SOCIALACCOUNT_PROVIDERS = { 'weixin': { 'APP': { 'client_id': 'YOUR_WEIXIN_APP_ID', 'secret': 'YOUR_WEIXIN_APP_SECRET', 'key': '' } } } python manage.py makemigrations python manage.py migrate html python from allauth.socialaccount.models import SocialAccount from django.contrib.auth.decorators import login_required @login_required def weixin_callback(request): social_account = request.user.socialaccount_set.filter(provider='weixin').get()


上一篇:
下一篇:
切换中文