gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 03:33:45 26 4
gpt4 key购买 nike

我是Django的新手,并且已经安装django-allauth。
我遵循了文档,但是在安装后的步骤中遇到了麻烦:

  1. Add a Site for your domain, matching settings.SITE_ID (django.contrib.sites app).

  2. For each OAuth based provider, add a Social App (socialaccount app).

  3. Fill in the site and the OAuth app credentials obtained from the provider.


我完全不了解这一部分。
我尝试注册该网站和社交帐户,但没有任何变化。另外,我看到我必须定义站点ID,因此将其放入设置中:
SITE_ID = '1'
拜托,有人可以帮我吗?任何帮助将不胜感激。
更新
我找到了一个教程,让我继续讲下去。我在Facebook上注册了一个应用程序,并获得了一个应用程序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.
当我试图在MYIP/帐户/个人资料/中登录我的网站时

最佳答案

  • 通过管理面板添加站点。由于我是在计算机上进行开发的,因此我将“域名”字段设置为“127.0.0.1:8000”设置了站点,而“显示名称”无关紧要。
  • 您settings.py中的SITE_ID需要与您通过管理面板添加的站点中的实际数据库ID相匹配。为此,您可以转到通过管理面板创建的网站的详细信息,然后查看ID号的网址。我的最终结果是“5”(我重新创建了几个站点,试图使其正常运行)。
  • 通过管理面板创建社交应用程序。这非常简单,因为您只需要通过提供商来设置应用程序(例如,在Facebook网站上创建Facebook应用程序),并使用他们提供的密码和应用ID即可填写django表单。确保将在步骤1中创建的django网站添加到在此步骤中创建的社交应用程序中。

  • 注意:我这样做并一直得到404。这是由于我以管理员身份登录,因此url'/accounts/login'决定我已经登录并重定向到'/accounts/profile',还不存在。一个简单的解决方法是清除django页面的cookie,然后再次访问“/accounts/login”。如果需要帮助,请发表评论。

    关于django-allauth:如何为我的域添加站点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22220523/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com