python - How can I use social-auth on my templates? -
i've setup social-auth use facebook , can login now, how carry user data template? how can use user data on template, example:
avatar here {{ user_city }}
thx!
there's few ways achieve once social_auth has been installed user has relationship usersocialauth
model provided social_auth
. you'll have read documentation how work facebook graph. can ask permissions via facebook dialog.
one way:
{{ user.social_auth.all.0 }} # et cetera
the nicer way using templatetag , open graph
<img src="{{ user|social_auth:'avatar' }}" /> @register.filter def social_auth(user, arg): try: social_user = usersocialauth.objects.get(user=user) except usersocialauth.doesnotexist: social_user = none if social_user , arg == "avatar": return "http://graph.facebook.com/"+social_user.uid+"/picture"
Comments
Post a Comment