Django: SocialApp matching query does not exist

心已入冬 提交于 2019-11-27 20:31:30

问题


I am facing a problem in django-allauth .

I configured localhost:9000/admin/ with following details

socialapp .

provider: Name: Client id: App ID, or consumer key Key: Secret: etc .

I set the SITE_ID = 2 (Because I changed the default site example.com to 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'} }

Now when I am going on url http://localhost:9000/accounts/facebook/login

I am getting Error : SocialApp matching query does not exist.

Please help me out what might i am doing wrong here .


回答1:


Using the Django admin you need to create a SocialApp listing your Facebook app credentials. Make sure that this app is attached to the proper site (as in, django.contrib.sites.models.Site).

In your case, there needs to be a django.contrib.sites.models.Site instance with id=2 (check the sites admin) that is listed as a site for the SocialApp.

If either the SocialApp is missing, or if it is created but not attached to a site matching your settings.SITE_ID, then allauth does not know what app to pick, resulting in the error message you listed above.




回答2:


It showed this error when I had SITE_ID = 1 in my settings.py, but it worked when I changed it to 2 -> SITE_ID = 2



来源:https://stackoverflow.com/questions/15409366/django-socialapp-matching-query-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!