2

I've followed the tutorial and the examples for django-facebook from https://github.com/tschellenbach/Django-facebook/tree/master/facebook_example

I've got it up and running (as in i've run syncdb and migrations, and integrated the javascript and css code into my template).

When I click the link in my template, it successfully connects to Facebook and I can authorize. However, when it redirects, I get an error:

Request Method: POST
Request URL:    http://127.0.0.1:8000/facebook/connect/?facebook_login=1
Django Version: 1.5.1
Exception Type: AttributeError
Exception Value:    user or profile didnt have attribute facebook_id
Exception Location: /usr/local/lib/python2.7/dist-packages/django_facebook/utils.py in get_user_attribute, line 109
Python Executable:  /usr/bin/python
Python Version: 2.7.3

This is within django-facebook's code, and I'm not sure if I've done something wrong with my setup. I've created my own UserProfile model which extends the abstract FacebookProfileModel class (I've tried using FacebookModel as well):

from django_facebook.models import FacebookProfileModel
from django.db.models.signals import post_save

class UserProfile(FacebookProfileModel):
    user = models.OneToOneField('auth.User')

def create_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)

post_save.connect(create_profile, sender=User)

I can see the profile get created in the db, although it's all nulls (except for the user id used in the foreign key). Not sure what I'm doing wrong, any pointers?

karthikr
  • 97,368
  • 26
  • 197
  • 188
Anil Beniwal
  • 45
  • 1
  • 6
  • Check if your database models for `FacebookProfileModel` are created properly. (Do you have to run a south migration if you added this model after running a syncdb ?) – karthikr Jun 22 '13 at 22:41

1 Answers1

1

I found out what was wrong, and want to post the solution back. The problem was that I didn't specify AUTH_PROFILE_MODULE in my settings.py. In the django-facebook documentation, it didn't mention that when it gave the option to extend the profile class, so I missed it. Silly mistake!

Anil Beniwal
  • 45
  • 1
  • 6