Django:SocialApp匹配查询不存在

时间:2013-03-14 12:30:46

标签: django django-allauth

我在django-allauth面临一个问题。

我为localhost:9000/admin/配置了以下详细信息

socialapp。

提供商: 名称: 客户ID: 应用程序ID或使用者密钥 键: 秘密:等等。

我设置了SITE_ID = 2(因为我将默认站点example.com更改为localhost:9000)

In setting.py


   INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
        'uni_form',
        'allauth',
        'allauth.account',
        'allauth.socialaccount',
        'bootstrapform',
        # 'allauth.socialaccount.providers.twitter',
        # 'allauth.socialaccount.providers.openid',
         'allauth.socialaccount.providers.facebook',
    )
    SOCIALACCOUNT_PROVIDERS = \
        { 'facebook':
            { 'SCOPE': ['email', 'publish_stream'],
              'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
              'METHOD': 'oauth2' ,
              'LOCALE_FUNC': 'path.to.callable'} }

现在我正在使用网址http://localhost:9000/accounts/facebook/login

我收到错误:SocialApp matching query does not exist.

请帮我解决一下我在这里做错了什么。

4 个答案:

答案 0 :(得分:48)

使用Django管理员,您需要创建一个SocialApp列出您的Facebook应用凭据。确保此应用已附加到正确的网站(如django.contrib.sites.models.Site)。

在您的情况下,需要{id}为django.contrib.sites.models.Site的实例(检查网站管理员),该实例列为SocialApp的网站。

如果SocialApp丢失,或者已创建但未附加到与settings.SITE_ID匹配的网站,则allauth不知道要选择的应用,导致您在上面列出的错误消息。

答案 1 :(得分:5)

就我而言,在添加社交应用页面上,我忘记选择"Chosen sites" ??‍♂️

作为我的网站

请参见下面的屏幕截图(右下方是“选择的网站”列表)enter image description here

答案 2 :(得分:1)

当我在settings.py中放入SITE_ID = 1时,显示了此错误,但是当我将其更改为2-> SITE_ID = 2

时,此错误起作用了

答案 3 :(得分:1)

第1步:转到您的管理页面。 查找social application

enter image description here

第2步:现在添加如下图所示的行。 提供您的客户端ID和google api提供的密钥,然后将available site (example.com)移至chosen sites enter image description here

第3步:现在转到管理页面侧面导航中的sites并像下图所示进行自定义并保存

enter image description here

第4步:现在,在settings.py文件中添加SITE_ID = 1

相关问题