I'm using django-allauth, and I configured localhost:9000/admin/
with the following details:
socialapp .
provider:
Name:
Client id:
App ID, or consumer key
Key:
Secret: etc .
I set SITE_ID = 2
(because I changed the default site example.com
to localhost:9000
)
In settings.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'} }
When I go to:
http://localhost:9000/accounts/facebook/login
I get:
Error : `SocialApp matching query does not exist.
What am I doing wrong?
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.
For me, it showed this error when I had in settings.py
:
SITE_ID = 1
It worked when I changed it to 2
:
SITE_ID = 2
In my case, on the Add social application page, I forgot to select my site as "Chosen sites"
🤦🏼♂️
See screenshot below (on the bottom right is the Chosen Sites list):
Step 1: Go to your admin page.
Find social application
Step 2: now add the lines like the following image.
Give your client id and secret key given by google api and move available site (example.com)
to chosen sites
Step 3: Now go to sites
in the side navigation of admin page and customize like the following image and save it
Step 4: now, add, SITE_ID = 1
in settings.py file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With