问题
I am trying to setup Django-allauth in my project. I am running into this error and am unable to fix it.
Environment:
Request Method: GET Request URL: `http://localhost:8000/accounts/login/`
Django Version: 1.4.2 Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'django.contrib.admin',
'django.contrib.admindocs')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Template error: In template
/media/Dump/Sites/wtr/allauth/templates/socialaccount/snippets/login_extra.html,
error at line 3 No Facebook app configured: please add a SocialApp
using the Django admin
1 : {% load socialaccount %}
2 :
3 : {% providers_media_js %}
4 :
5 :
I actually configured a facebook app in Django Admin but can't understand why it's giving this exception.
Exception Type: ImproperlyConfigured at /accounts/login/ Exception
Value: No Facebook app configured: please add a SocialApp using the
Django admin
- I added allauth apps to the
INSTALLED_APPLICATIONS
- Added that
TEMPLATE_CONTEXT_PROCESSORS
setting - Edited the setting,
AUTHENTICATION_BACKENDS
- Added
allauth
urls inurls.py
Is this all that is required to be done or is there some more? If yes, could you please point me to the relevant docs?
回答1:
The problem could be with your database. Think you need to synchronize the Database.
DO
python manage.py syncdb
if that does not work, make sure the Site
which you added your facebook app to has the domain localhost:8000
if you are using localhost or 127.0.0.1:8000
if you are using 127.0.0.1:8000
For more information go through this allauth tutorial.
UPDATE
you could also try removing the example.com
site from the admin and add a new site that uses localhost:8000
or 127.0.0.1:8000
and add the facebook social app under the new site. Also, do not forget to set the SITE_ID
variable in your settings.py
file.
回答2:
I had the same issue here and the problem was the SITE_ID, which is 1 by default. However, 1 is assigned to the example site that comes by default when you see the admin panel. After creating my site for configuring a Facebook login, I replaced the SITE_ID=2 in settings.py and it worked. Another option is to delete the example site, but it will appear again if at some point you delete your db and create it again.
This took me like 3 hours until I realized... :S
回答3:
I had the same problem and I think some explanation will help others: django-allauth uses django-sites which can make it very confusing.
It's very easy to accidentally add sites when you are configuring your social app.
To get things working, you need to make sure that the SITE_ID in your settings matches the domain that you've enabled in your facebook app and selected in the social app on the django back end. If the site specified in any one of these three locations is wrong, you'll get the 'ImproperlyConfigured...' error.
If, like me, you got it all messed up from the start, do this to get facebook authentication working:
- Go to your facebook app and record the 'Site URL' - This is the only
site your facebook app will authenticate. For testing I'm using
'
http://localhost:8000
'. Call this mysite. - Go to your facebook social app in django admin and make sure you've got mysite as the only site in 'chosen sites'. Add it using admin/sites if it's not on the list.
- Go to admin/sites and delete anything that should not be there.
- Use phpmyadmin or some such to look at your django_site table and record the site_id for mysite.
- Update your settings so that SITE_ID is set to the mysite id.
run your server and facebook authentication should work.
回答4:
I faced the same problems and thanks everyone for useful suggestions. Here is my solution recipe: (i made chmod +x manage.py
)
1) ./manage.py syncdb
2*) ./manage.py schemamigration --initial socialaccount
(register new app on fb and add new Social app through admin)
3) ./manage.py shell
> from django.contrib.sites.models import Site
> site = Site.objects.create(domain='foo.com', name='foo.com')
> site.id
> ^C [y]
4) settings.py > add SITE_ID = 'your site.id'
5) test localhost:8000/accounts/login/
*schemamigration is used with installed South (!)
回答5:
What worked for me was, under Available Sites, choose (in this case example.com which is default SITE_ID name) and add to the right Chosen Sites, then save when creating a Social Application

回答6:
The site_id
in the settings.py must match the django admin entry for your site (during testing it might be localhost:8000). This is located in the "sites" choice under the "sites" heading (again, in the admin). To get your site_id
... click on "sites". Note: just because you have 2 entries and the 2nd is yours doesn't mean the site_id = 2
. Click on your entry and then note in the address bar the number. This is covered above and elsewhere, but being new to coding I needed more explicit instructions.
see the 3 in the pic? Well it was my 2nd of 2 entries in "sites"
回答7:
While it may seem obvious, first log into the facebook developer page and create a new app.
Next go to the djagno admin site and click on the add button for Social Applications.
Save and set up SITE_ID as others have mentioned, so this solved my problem with "No Facebook app configured".
来源:https://stackoverflow.com/questions/14019017/django-allauth-no-facebook-app-configured-please-add-a-socialapp-using-the-djan