2

I'm successfully using django-facebook to login facebook users ( e.g, after login, the template tag {{ user }} shows the facebook username). however, it doesn't make it to admin interface - and under facebook users there is no data at all.

also, the SQL table django_facebook_facebookcustomuser is showing the user data.

my guess was that i needed to register the FacebookCustomUser model in admin.py, so i did this -

class FacebookCustomUserAdmin(admin.ModelAdmin):
    pass

admin.site.register(models.FacebookCustomUser, FacebookCustomUserAdmin)

# and commented out the user admin inteface -
#admin.site.register(models.FacebookUser, FacebookUserAdmin)

it solved the problem, but in a very hackish way... I now have a 'users' table, showing the different users, but the 'open graph share' and 'like' sections are still not populated with any data from the db.

when i actually try to pass something inside the CustomUser class, as in the original code -

 class FacebookCustomUserAdmin(admin.ModelAdmin):
    list_display = ('user_id', 'name', 'facebook_id',)
    search_fields = ('name',)

i get the following http500 error -

FacebookCustomUserAdmin.list_display[0], 'user_id' is not a callable or an attribute of 'FacebookCustomUserAdmin' or found in the model 'FacebookCustomUser'.

does anyone have an idea on how i can correctly register the facebook users ( as well as the other django-facebook models ) to the admin site?

thanks a lot!

DataB
  • 161
  • 1
  • 2
  • 8

1 Answers1

0

Two pointers:

  1. Extend UserAdmin instead of ModelAdmin.
  2. Use id instead of user_id.

Try this:

from django.contrib import admin
from django_facebook import models
from django.contrib.auth.admin import UserAdmin

class AccountAdmin(UserAdmin):
    list_display = ('id', 'username', 'email', 'facebook_id')

admin.site.register(models.FacebookCustomUser, AccountAdmin)

In settings.py you will need to add the following options to make sure likes and friends are saved:

FACEBOOK_STORE_LIKES = True
FACEBOOK_STORE_FRIENDS = True
sdobson
  • 143
  • 1
  • 5