Connect FanDjango user to Django User (e.g., add more attributes)
edanm opened this issue · 4 comments
Hi,
I'm new to FanDjango, and trying to understand something. I've got everything set up and working beautifully, and I can pole request.facebook.user and get info.
But now, I want to develop an application that has more info than just Facebook gives me about each user. For example, I want to store up/down votes this user has mode on other objects (i.e. relations). I want to store user settings. Etc... The standard "Django Way" is to use a User Profile, but I don't know how to connect FanDjango's user to the user profile.
I'm unclear how to do this.
I looked into django-facebook before fandjango, and I couldn't get it to work which is why I moved to this. What they do is, they allow your user-profile to inherit from their user definition. Can the same kind of thing work here, or should I be doing something different?
Thanks,
And thanks for an incredibly easy-to-use package which actually just worked!
Edan
Hi edanm,
I think there are many possibilities. I personally have a profile model, which has a OneToOne Field that references fandjango's User model.
from fandjango.models import User
class Profile(models.Model):
user = models.OneToOneField(User, related_name='profile')
...
Then I just listen for the post_save signal of "Fandjango.models.User" and when the "created" parameter is set, I instantiate the Profile model.
@receiver(post_save, sender=User)
def profile_creation(sender, instance, created, **kwargs):
if created:
profile, created = Profile.objects.get_or_create(user=instance)
Hi Morpho,
Yeah, that sounds like what I'm going to do as well.
I think it would be a good idea to have a reference of this in the documentation, since many people probably wonder what's the best way to do this.
FWIW, I do the same thing as @Morpho in my Fandjango project.