Question

I need to add a BooleanField and a ManyToManyField to my users. I'm using django-social-auth. It seems I could use 'CustomUser'. I guess that's what it's for, but how do I take it into use?

I would need to know:

  1. where to define these new fields
  2. How to add them to the new user when the user is created (ie logs in)
  3. How the query the fields afterwards (ie User.myBooleanField?)

Thanks!

Was it helpful?

Solution

Create a model called CustomUser or UserProfile, whatever you want, with these fields.

In settings.py add a setting AUTH_PROFILE_MODULE = "account.UserProfile", with what you named your model.

In the signals for social_auth, make sure the user has a profile, and if not create it for them when the user is created.

Now anywhere in the site you can call user.get_profile() and you'll have access to these fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top