Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11523

Python Social Auth. relate to existing Profiles model

I just included python social auth and added Facebook login. I have a Profile model where I save some user data like "description" and "username".

class Profile(models.Model):
    username = models.CharField(max_length=75)
    user_des = models.CharField(max_length=250, blank=True, null=True)
    ...

How do I relate the user's Facebook account to the existing model, and where do I save that relation?

Upvotes: 1

Views: 507

Answers (1)

TPOT94
TPOT94

Reputation: 128

Looking at the social auth docs I found that you can specify custom user models using this in your settings.py:

SOCIAL_AUTH_USER_MODEL = 'myapp.CustomUser'

In your case it will be:

SOCIAL_AUTH_USER_MODEL = 'myapp.Profile'

The docs I found this on are here:

http://django-social-auth.readthedocs.org/en/latest/configuration.html#custom-user-model

They also include documentation of ORMs here:

http://django-social-auth.readthedocs.org/en/latest/configuration.html#orms

edit:

By default social-auth uses the

django.contrib.auth.User

model to save users, the documentation can be found here:

https://docs.djangoproject.com/en/dev/ref/contrib/auth/

Upvotes: 1

Related Questions