[Answered ]-Django social_auth custom user model FacebookBackend explanation

2👍

There are a couple of ways to archive it, what fits better to your project is up to you of course, here’s a list of available options:

  1. Define this setting FACEBOOK_EXTRA_DATA = ('gender', 'locale'), the values will be available at the UserSocialAuth instance, to get them just do user.social_auth.get(provider='facebook').extra_data['gender'] or ['locale']. This is possible just because the information is available in the basic user data response.

  2. Use a user profile to store this data (check django doc about it). Then just add a pipeline entry that stores the values in your profile instance.

  3. Create a custom user model, SOCIAL_AUTH_USER_MODEL = 'myapp.CustomUser', and again add a custom pipeline entry that stores the values in your user instance.

Number 1 is not the best solution IMO, since a user can have several Facebook accounts connected and it could create a mess. Number 2 is good for Django 1.4 and lower, but it’s deprecated starting from Django 1.5, something to take into account. Number 3 is a bit messy IMO.

👤omab

Leave a comment