I am using:
- django-social-auth v 0.7.19
- django 1.4.3
models.py:
class UserProfile(models.Model):
user = models.ForeignKey(User)
username = models.CharField(max_length = 64, blank = True, null = True)
last_login = models.DateField(blank = True, null = True)
is_active = models.BooleanField(blank = True)
social_auth pipeline.py:
from social_auth.backends.pipeline.user import create_user
def create_user(backend, details, response, uid, username, user=None, *args,
**kwargs):
if user:
return {'user': user}
if not username:
return None
user, created = User.objects.get_or_create(username = username)
profile, created = UserProfile.objects.get_or_create(user = user)
return {
'user': user,
'profile' : profile,
'is_new': True
}
Problem:
When I take out the fields username, last_login and is_active from my model, the social auth would give me a DataBaseError as these columns are necessary. I am taking ForeignKey User but it cannot detect it.
I am overriding the create_user method of social auth to create my user and their profile. When the function returns, a user and profile is created but still it redirects on the error page. Cannot figure out why.