I'm using django-social-auth, and I'm really impressed by its simplicity, however I use a custom user model and I overrided the save()
method in order to set a default computed value for a field I need, the problem is that save()
is not called by socialauth! How can this be possible? Is there another way of setting a computed field value at creation-time?
Asked
Active
Viewed 678 times
0

daveoncode
- 18,900
- 15
- 104
- 159
-
Have you tried changing the social-auth pipeline? http://django-social-auth.readthedocs.org/en/latest/pipeline.html – finiteautomata Sep 26 '13 at 14:23
-
yes I've already solved my problem, I forget to post my solution :P – daveoncode Sep 26 '13 at 14:43
-
can you post your solution and your code? I have a similar problem, and I think your solution may help me. – jackiekazil Nov 30 '13 at 22:57
-
Sure Jack… let me know if it's helpful ;) – daveoncode Dec 01 '13 at 10:14
1 Answers
0
In order to solve the problem I created a custom "pipeline" (com.mysite.apps.users.social_auth.pipeline.addFacebookDetails) in which I add the necessary data to the user model only during its creation:
in settings.py:
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'com.mysite.apps.users.social_auth.pipeline.addFacebookDetails',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.user.update_user_details',
)
in com.mysite.apps.users.social_auth.pipeline.addFacebookDetails.py:
def addFacebookDetails(*args, **kwargs):
if kwargs['is_new']:
user = kwargs['user']
user.field1 = 'foo'
user.field2 = 'bar'
return None

daveoncode
- 18,900
- 15
- 104
- 159