1

I would like to save data I get with allauth package after signing up using facebook.

I made a custom user :

class AppUser(models.Model):
    birthdate = models.DateTimeField(null=True, blank=True)
    address = adress_model.AddressField(null=True, blank=True)
    image = models.ImageField(upload_to=get_image_path, blank=True, null=True)
    gender = models.TextField(null=True, blank=True)
    user = models.OneToOneField(User)

I would like to store all data in the database so I can easily access it from database.

P.S: If u can tell me how I can make a login page with button that will trigger it as well it would be great!

Gal Fridman
  • 730
  • 1
  • 8
  • 19

1 Answers1

0

You can either use the save() method of the model to extract and save the data:

save(self, *wargs, **kwargs)
    social_account = self.socialaccount_set.get(provider="facebook")
    self.first_name = social_account.extra_data['first_name']
    super(User, self).save(*wargs, **kwargs)

Or you can use the provided signal by allauth:

allauth.socialaccount.signals.social_account_added(request, sociallogin)

Check here for signal docs: http://django-allauth.readthedocs.io/en/latest/signals.html

Özer
  • 2,059
  • 18
  • 22