Add url(r'^login/$', 'social_auth.views.auth', {'backend': 'google'}, name='login') to your urls.py.
Add the app to your INSTALLED_APPS after django.contrib.admin.
Set USE_SOCIAL_AUTH_AS_ADMIN_LOGIN = True in your settings.py.
...
Profit.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fromdjango.confimportsettingsfromdjango.contribimportadminfromdjango.contrib.auth.viewsimportredirect_to_loginfromdjango.core.exceptionsimportPermissionDenied# Support for allowing social_auth authentication for /admin (django.contrib.admin)ifgetattr(settings,'SOCIAL_AUTH_USE_AS_ADMIN_LOGIN',False):def_social_auth_login(self,request,**kwargs):ifrequest.user.is_authenticated():ifnotrequest.user.is_activeornotrequest.user.is_staff:raisePermissionDenied()else:returnredirect_to_login(request.get_full_path())# Overide the standard admin login form.admin.sites.AdminSite.login=_social_auth_login
Comments
Please login first before commenting.