Last Updated: February 25, 2016
·
4.258K
· mayuroks

Django Allauth quick setup

http://djangosteps.wordpress.com/2013/09/19/setting-up-django-allauth/

1) INSTALLATION
pip install django-allauth

TEMPLATECONTEXTPROCESSORS = (
"django.core.contextprocessors.request",
"django.contrib.auth.context
processors.auth", ## ADD MANUALLY
"allauth.account.contextprocessors.account",
"allauth.socialaccount.context
processors.socialaccount",
)

INSTALLED_APPS = (
'allauth',
'allauth.account',
'allauth.socialaccount',
'django.contrib.sites', ## ADD MANUALLY
# ... include the providers you want to enable:
'allauth.socialaccount.providers.dropbox',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.instagram',
'allauth.socialaccount.providers.linkedin',
)

2) urls.py:

urlpatterns = patterns('',
(r'^accounts/', include('allauth.urls')),
)

3) ./manage.py syncdb

4) Access /accounts/login to login
/accounts/logout to logout

5) After login you will be redirected to /accounts/profile/
which can be easily modified by

urls.py:
url(r'^accounts/profile/', ProfileView.as_view(), name='profile')

views.py:
from django.views.generic import ListView
from appfornotes.models import Post
# Create your views here.
class ProfileView(ListView):
model = Post
templatename = 'base.html'
# template
name = 'appfornotes/index.html'

Copy templates from package templates and store some where

6) For user info allauth uses Django User models, make foreignKey to User model

In templates access user info like this

<h1>HELLO {% userdisplay user %}</h1>

You're logged in with {{ user.get

provider }} as {{ user.firstname }} {{ user.lastname }}.</p>