I'm using django_facebook. Each time a user registers with fb, her profilpicture is loaded on a field called 'image'
In my models.py I have a field, named profilpic, to allow users to have a profil picture:
class UserProfile(FacebookProfileModel):
user = models.OneToOneField(User)
profilpic = models.ImageField(upload_to="profilepics/", default="profilepics/shadow_user.jpg")
def create_facebook_profile(sender, instance, created, **kwargs):
if not created:
return
UserProfile.objects.create(user=instance)
post_save.connect(create_facebook_profile, sender=User)
What I would like to do is when a user registers with facebook, the 'profilpic' takes the value of 'image' (i.e profilpic becomes the facebook picture).
Here is what I tried:
def create_facebook_profile(sender, instance, created, **kwargs):
if not created:
return
UserProfile.objects.create(user=instance)
instance.userprofile.profilpic = instance.userprofile.image
instance.save()
post_save.connect(create_facebook_profile, sender=User)
But it doesn't work. Any idea on how to accomplish that?
Thank you very much.