Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-allauth: How can I add a Site for my domain?

I'm new to Django and I've installed django-allauth.

I followed the docs, but I'm stuck on the Post-Installation steps:

  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.

I don't understand this part at all.

I tried to register the site & socialaccount but nothing changes. Also, I saw that I had to define Site ID so I put this in my settings:

SITE_ID = '1'

Please, could anybody help me with this? Any help will be appreciated.

UPDATE

I found a tutorial that let me go on with this. I registered an app in facebook and I obtained a APP ID & secret and I established by /admin/socialaccount/socialapp/ but even when all is ready i get

      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.

when im trying to check in my website in MYIP/accounts/profile/

like image 827
user3387367 Avatar asked Mar 06 '14 09:03

user3387367


1 Answers

  1. Add a Site through the admin panel. Since I am developing on my machine, I've set up my site with the "Domain Name" field set as "127.0.0.1:8000" and the "Display Name" shouldn't matter.

  2. Your SITE_ID in settings.py needs to match the actual database ID from the Site you added through the admin panel. To do this you can go to the details of the Site you created through the admin panel and look at the url for the ID number. Mine ended up being "5"(I recreated several sites trying to get this to work).

  3. Create a Social Application through the admin panel. This is pretty easy as you only need to setup an Application through the provider (e.g. create a Facebook app on Facebooks website) and use the secret code and app ID they give you to fill out the django form. Be sure to add the django Site you created in step 1 to the Social Application you are making in this step.

NOTE: I did this and kept getting a 404. This was due to me being logged in as an admin, thus, the url '/accounts/login' decided I was already logged in and redirected to '/accounts/profile' which didn't exist yet. An easy fix if you run into this is to clear your cookies for your django page and visit '/accounts/login' again. Post in comments if you need help.

like image 190
Dylan Avatar answered Sep 27 '22 21:09

Dylan