I'm looking to use an Account model I created to handle financial data about a user. How do I ensure django-allauth will create this model when registering users and will link through keys both the new user and the Account model?
Asked
Active
Viewed 84 times
1 Answers
1
You can implement custom pipeline. First modify SOCIAL_AUTH_PIPELINE
in django settings
file like this:
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
'yourapp.pipeline.add_account'
)
Then in yourapp
create pipeline
module or you can use already existing model and inside this model create function add_account
with following code:
def add_account(backend, details, response, user=None, is_new=False, *args, **kwargs):
if is_new:
Account.objects.create(user=user)
You can find more details here and here.
UPDATE
Pipelines is just functions wich will be called by django-allauth during autentication process. So you can add some custom function to this procedure.

neverwalkaloner
- 46,181
- 7
- 92
- 100
-
I'm not familiar with how pipelines work, can you provide more details please? – Alex Creamer Aug 30 '17 at 17:59
-
How come you put user=user for the Account creation? Don't I only need to use a pk? – Alex Creamer Aug 31 '17 at 18:12
-
Plus, why are there so many pipelines specified from social.pipeline – Alex Creamer Aug 31 '17 at 18:20
-
@AlexCreamer since user argument is an object it is more simple to pass objects to queryset. But you can use id as well. I just copied pipelines from project. You can remove some of them. – neverwalkaloner Aug 31 '17 at 18:23
-
I tried using your suggestion and I was unable to get def add_account called after user registration – Alex Creamer Aug 31 '17 at 22:51