Django social auth to update profile model

335 views Asked by At

I am using django-social-auth. Everything works fine except that profile model is not updated. I have a OneToOneField with USER table. Whenver a user registers on site using e-mail, his profile is created automatically. However when login with social credentials, profile is not automatically created. What changes needs to be done for this to work. Thank you.

Profile.py

class Profile(models.Model):
    user=models.OneToOneField(settings.AUTH_USER_MODEL)
    contact_number= models.CharField(max_length=250,null=True,blank=True)
    official_email= models.EmailField(null=True,blank=True)
    website= models.CharField(max_length=250,null=True,blank=True)
    address = models.TextField(null=True,blank=True)
    city = models.CharField(max_length=250,null=True,blank=True)
1

There are 1 answers

1
Rochan On

In Urls:

url('', include('social.apps.django_app.urls', namespace='social')),
url('', include('django.contrib.auth.urls', namespace='auth')),

in settings

LOGIN_REDIRECT_URL = '/djsite'

SOCIAL_AUTH_FACEBOOK_KEY = '234839666xxxxxx'
SOCIAL_AUTH_FACEBOOK_SECRET = 'c42dcdadf8902c4108b47c5de9xxxxxx'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'email'}

Rest you can find on: Bogotobogo