django-allauth:如何为我的域名添加网站?

use*_*367 7 django django-authentication django-allauth

我是Django的新手,我已经安装了django-allauth.

我按照文档进行操作,但是我坚持使用安装后的步骤:

  1. 为您的域添加网站,匹配settings.SITE_ID(django.contrib.sites app).

  2. 对于每个基于OAuth的提供商,请添加社交应用(socialaccount应用).

  3. 填写从提供商处获得的站点和OAuth应用凭据.

我根本不明白这一部分.

我试图注册该网站&socialaccount但没有任何变化.另外,我看到我必须定义站点ID,所以我把它放在我的设置中:

SITE_ID = '1'
Run Code Online (Sandbox Code Playgroud)

拜托,有人可以帮帮我吗?任何帮助将不胜感激.

UPDATE

我找到了一个教程,让我继续这个.我在Facebook注册了一个应用程序,我获得了一个APP ID和秘密,我建立了/ admin/socialaccount/socialapp /但即使一切准备就绪我得到了

      Page not found (404)
Request Method: GET
Request URL:    MyIP/accounts/profile/
Using the URLconf defined in gameproject.urls, Django tried these URL patterns, in this order:
^admin/
^accounts/ ^ ^signup/$ [name='account_signup']
^accounts/ ^ ^login/$ [name='account_login']
^accounts/ ^ ^logout/$ [name='account_logout']
^accounts/ ^ ^password/change/$ [name='account_change_password']
^accounts/ ^ ^password/set/$ [name='account_set_password']
^accounts/ ^ ^inactive/$ [name='account_inactive']
^accounts/ ^ ^email/$ [name='account_email']
^accounts/ ^ ^confirm-email/$ [name='account_email_verification_sent']
^accounts/ ^ ^confirm-email/(?P<key>\w+)/$ [name='account_confirm_email']
^accounts/ ^ ^confirm_email/(?P<key>\w+)/$
^accounts/ ^ ^password/reset/$ [name='account_reset_password']
^accounts/ ^ ^password/reset/done/$ [name='account_reset_password_done']
^accounts/ ^ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
^accounts/ ^ ^password/reset/key/done/$ [name='account_reset_password_from_key_done']
^accounts/ ^social/
^accounts/ ^weibo/
^accounts/ ^persona/login/$ [name='persona_login']
^accounts/ ^instagram/
^accounts/ ^openid/login/$ [name='openid_login']
^accounts/ ^openid/callback/$ [name='openid_callback']
^accounts/ ^vimeo/
^accounts/ ^twitter/
^accounts/ ^vk/
^accounts/ ^linkedin/
^accounts/ ^github/
^accounts/ ^google/
^accounts/ ^facebook/
^accounts/ ^facebook/login/token/$ [name='facebook_login_by_token']
^accounts/ ^facebook/channel/$ [name='facebook_channel']
^accounts/ ^angellist/
^accounts/ ^bitly/
^accounts/ ^dropbox/
^accounts/ ^stackexchange/
^accounts/ ^twitch/
^accounts/ ^soundcloud/
The current URL, accounts/profile/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Run Code Online (Sandbox Code Playgroud)

当我试图在MYIP/accounts/profile /中检查我的网站时

Dyl*_*lan 8

  1. 通过管理面板添加网站.由于我在我的机器上进行开发,因此我将"域名"字段设置为"127.0.0.1:8000"并且"显示名称"无关紧要.

  2. settings.py中的SITE_ID需要与您通过管理面板添加的站点中的实际数据库ID相匹配.为此,您可以转到通过管理面板创建的站点的详细信息,并查看ID号的URL.我最终成为"5"(我重新创建了几个试图让它工作的网站).

  3. 通过管理面板创建社交应用程序.这很简单,因为您只需要通过提供商设置应用程序(例如在Facebook网站上创建Facebook应用程序)并使用他们为您填写django表单的密码和应用程​​序ID.请务必将您在步骤1中创建的django站点添加到您在此步骤中创建的社交应用程序中.

注意:我这样做并继续获得404.这是因为我以管理员身份登录,因此,网址'/ accounts/login'决定我已经登录并重定向到'/ accounts/profile'还没存在.如果遇到这种情况,一个简单的解决方法是清除django页面的cookie并再次访问"/ accounts/login".如果您需要帮助,请在评论中发帖.


Muh*_*aqi -2

安装后

在 Django 根目录中执行以下命令来创建数据库表:

python manage.py syncdb
Run Code Online (Sandbox Code Playgroud)

现在启动您的服务器,访问您的管理页面(例如http://localhost:8000/admin/)并按照以下步骤操作:

  1. 为您的域添加一个匹配的站点settings.SITE_IDdjango.contrib.sites应用程序)。
  2. 对于每个OAuth基于的提供商,添加一个Social App(社交帐户应用程序)。
  3. 填写从 获得的站点和OAuth应用程序。credentialsprovider

在此输入图像描述