Django-facebook icon indicating copy to clipboard operation
Django-facebook copied to clipboard

FacebookProfile filled in correctly, but only name and surname show up in example.html

Open marcoforlin opened this issue 10 years ago • 6 comments

Hello all,

I am using the example on Django 1.49, facebook login works correctly and all user data are added to FacebookProfile.

However only {{ user.first_name }} and {{ user.last_name }} show on the example.html.

The others, like {{ user.profile_or_self.about_me }} don't work.

It works if I use this: {{ user.get_profile.about_me }}

best regards, and thanks for the nice work

Marco

marcoforlin avatar Nov 04 '13 23:11 marcoforlin

I'm running 1.5.4 and it's showing data for gender, facebook id, date of birth...

Can you help me reproduce this?

tschellenbach avatar Nov 29 '13 15:11 tschellenbach

I'm experiencing this same issue. Let me clean up some code and paste my settings / models, I'm sure we're just setting up the DB incorrectly or something.

Spencatro avatar Nov 29 '13 21:11 Spencatro

Running on Django 1.5.4:

Relevant portions of settings.py:

  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2',       'mysql', 'sqlite3' or 'oracle'.
          'NAME': '/opt/django/mydb.db',                      # Or path to database       file if using sqlite3.
          # The following settings are not used with sqlite3:
          'USER': '',
          'PASSWORD': '',
          'HOST': '',                      # Empty for localhost through domain       sockets or '127.0.0.1' for localhost through TCP.
          'PORT': '',                      # Set to empty string for default.
      }
  }

  #
  #..unimportant unedited settings.py contents
  #

  ## django_facebook
  FACEBOOK_APP_ID = 'my_facebook_app_id'
  FACEBOOK_APP_SECRET = 'my_facebook_app_secret'
  ##of course these contain my real app info

  LOGIN_REDIRECT_URL = '/games/'
  FACEBOOK_LOGIN_DEFAULT_REDIRECT = '/games/'

  #I assume this is where something is going wrong

  AUTH_PROFILE_MODULE = 'games.MyCustomProfile'
  TEMPLATE_CONTEXT_PROCESSORS = (
      'django.contrib.auth.context_processors.auth',
      'django.core.context_processors.debug',
      'django.core.context_processors.i18n',
      'django.core.context_processors.media',
      'django.core.context_processors.static',
      'django.core.context_processors.tz',
      'django.core.context_processors.request',
      'django.contrib.messages.context_processors.messages',
      'django_facebook.context_processors.facebook',
  )

  AUTHENTICATION_BACKENDS = (
      'django_facebook.auth_backends.FacebookBackend',
      'django.contrib.auth.backends.ModelBackend',
  )

games.models.py

  from django.db import models
  from django_facebook.models import FacebookProfileModel
  from django.contrib.auth.models import UserManager
  # Create your models here.

  class MyCustomProfile(FacebookProfileModel):
      user = models.OneToOneField('auth.user')
      objects = UserManager()

  from django.contrib.auth.models import User
  from django.db.models.signals import post_save

  #Make sure we create a MyCustomProfile when creating a User
  def create_facebook_profile(sender, instance, created, **kwargs):
      if created:
          MyCustomProfile.objects.create(user=instance)

  post_save.connect(create_facebook_profile, sender=User)      

Let me know if anything else would be helpful to reproduce, I'm really struggling here. I'm about to give up and just learn the OpenGraph API but I really don't have time to do that right now :/

Spencatro avatar Nov 29 '13 21:11 Spencatro

Also, here's a sample of what raw_data is storing in the database:

{"website": "Spencer-Hawkins.com", "last_name": "Hawkins", "locale": "en_US", "hometown": {"id": "154754277895542", "name": "Tamuning, Guam"}, "image": "https://graph.facebook.com/me/picture?access_token=CAADeM5AbHLYBADGZCz3u5FWCWZCZC1Qwh4s8ZAlVr5yElKejvd05mzVBqQJtdRiW1RKGFk19BFf7gUH7HroOESfFpUvhZBGPqZC0qcceqXcrYz766JzOlZB0gnZCAOhOTkbkQTZB2KNvuOVznbbbPaZBOsnyqq8iJepg22BSuPFa5fTNL98jJcUJct&type=large", "quotes": "\"If you can't laugh at yourself, life is going to seem a whole lot longer than you'd like.\"\n\n--Sam, Garden State", "timezone": -8, "education": [{"school": {"id": "108015725885605", "name": "Klein Oak High School"}, "type": "High School", "year": {"id": "201638419856163", "name": "2011"}}, {"school": {"id": "105709269462549", "name": "University of Texas at Dallas"}, "type": "College", "concentration": [{"id": "104076956295773", "name": "Computer Science"}], "year": {"id": "105576766163075", "name": "2015"}}], "id": "580422245", "first_name": "Spencer", "verified": true, "location": {"id": "108233179205482", "name": "Richardson, Texas"}, "image_thumb": "https://graph.facebook.com/me/picture?access_token=CAADeM5AbHLYBADGZCz3u5FWCWZCZC1Qwh4s8ZAlVr5yElKejvd05mzVBqQJtdRiW1RKGFk19BFf7gUH7HroOESfFpUvhZBGPqZC0qcceqXcrYz766JzOlZB0gnZCAOhOTkbkQTZB2KNvuOVznbbbPaZBOsnyqq8iJepg22BSuPFa5fTNL98jJcUJct", "email": "[email protected]", "username": "shawkinsl", "bio": "Removed due to offensive copyright infringement", "birthday": "09/28/1992", "link": "https://www.facebook.com/shawkinsl", "name": "Spencer Hawkins", "gender": "male", "work": [{"position": {"id": "105549279479057", "name": "Technician"}, "description": "Assembling, Soldering, QC/Testing, Troubleshooting various interfacing Circuit Boards that are deployed on OEM oil rigs.", "location": {"id": "107925612568471", "name": "Plano, Texas"}, "start_date": "2011-10-01", "employer": {"id": "133670130018876", "name": "Precise Circuits"}}, {"description": "I don't know yet, but man am I excited!", "end_date": "2014-05-29", "employer": {"id": "18790602800", "name": "Tesla Motors"}, "location": {"id": "104022926303756", "name": "Palo Alto, California"}, "position": {"id": "656983747675334", "name": "Powertrain Validation and Test Engineering Intern"}, "start_date": "2014-01-06"}, {"position": {"id": "108703555821060", "name": "Intern"}, "start_date": "2013-06-19", "location": {"id": "105396882827337", "name": "Pasadena, California"}, "end_date": "2013-08-31", "employer": {"id": "8261258923", "name": "Jet Propulsion Laboratory (JPL)"}}, {"description": "http://www.google.com/search?client=safari&rls=en-us&q=define:barback&ie=UTF-8&oe=UTF-8", "end_date": "2011-06-01", "employer": {"id": "148354981878238", "name": "Santikos"}, "location": {"id": "107879769240188", "name": "Tomball, Texas"}, "position": {"id": "208170149275530", "name": "Bartender"}, "start_date": "2008-09-01"}, {"description": "clearing Fancy tables of Fancy plates that once held Fancy food but was eaten by Fancy clients.", "end_date": "2009-06-01", "employer": {"id": "1391646277732473", "name": "Lobster Shop Dash"}, "location": {"id": "108537252503370", "name": "Dash Point, Washington"}, "position": {"id": "110448272309606", "name": "Busser"}, "start_date": "2008-06-01"}], "updated_time": "2013-11-29T20:56:44+0000"}

I figure it might be useful to know that the data is actually getting across, but somehow it's being accessed or stored improperly or something. I'm actually about to open a separate ticket for an issue I'm having, but I can reproduce this issue, and I'm betting that fixing this one might fix the other issue I'm having as well.

Spencatro avatar Nov 29 '13 21:11 Spencatro

That looks very similar to the example app. Will do some digging in the coming days.

Does the data get stored in thw database? Ie is this a read or write issue? On Nov 29, 2013 10:38 PM, "Spencer Hawkins" [email protected] wrote:

Also, here's a sample of what raw_data is storing in the database:

{"website": "Spencer-Hawkins.com", "last_name": "Hawkins", "locale": "en_US", "hometown": {"id": "154754277895542", "name": "Tamuning, Guam"}, "image": "https://graph.facebook.com/me/picture?access_token=CAADeM5AbHLYBADGZCz3u5FWCWZCZC1Qwh4s8ZAlVr5yElKejvd05mzVBqQJtdRiW1RKGFk19BFf7gUH7HroOESfFpUvhZBGPqZC0qcceqXcrYz766JzOlZB0gnZCAOhOTkbkQTZB2KNvuOVznbbbPaZBOsnyqq8iJepg22BSuPFa5fTNL98jJcUJct&type=large", "quotes": ""If you can't laugh at yourself, life is going to seem a whole lot longer than you'd like."\n\n--Sam, Garden State", "timezone": -8, "education": [{"school": {"id": "108015725885605", "name": "Klein Oak High School"}, "type": "High School", "year": {"id": "201638419856163", "name": "2011"}}, {"school": {"id": "105709269462549", "name": "University of Texas at Dallas"}, "type": "College", "concentration": [{"id": "104076956295773", "name": "Computer Science"}], "year": {"id": "105576766163075", "name": "2015"}}], "id": "580422245", "first_name": "Spencer", "ve rified": true, "location": {"id": "108233179205482", "name": "Richardson, Texas"}, "image_thumb": "https://graph.facebook.com/me/picture?access_token=CAADeM5AbHLYBADGZCz3u5FWCWZCZC1Qwh4s8ZAlVr5yElKejvd05mzVBqQJtdRiW1RKGFk19BFf7gUH7HroOESfFpUvhZBGPqZC0qcceqXcrYz766JzOlZB0gnZCAOhOTkbkQTZB2KNvuOVznbbbPaZBOsnyqq8iJepg22BSuPFa5fTNL98jJcUJct", "email": "[email protected]", "username": "shawkinsl", "bio": "Removed due to offensive copyright infringement", "birthday": "09/28/1992", "link": "https://www.facebook.com/shawkinsl", "name": "Spencer Hawkins", "gender": "male", "work": [{"position": {"id": "105549279479057", "name": "Technician"}, "description": "Assembling, Soldering, QC/Testing, Troubleshooting various interfacing Circuit Boards that are deployed on OEM oil rigs.", "location": {"id": "107925612568471", "name": "Plano, Texas"}, "start_date": "2011-10-01", "employer": {"id": "133670130018876", "name": "Precise Circuits"}}, {"description": "I don't know yet, but man am I ex cited!", "end_date": "2014-05-29", "employer": {"id": "18790602800", "name": "Tesla Motors"}, "location": {"id": "104022926303756", "name": "Palo Alto, California"}, "position": {"id": "656983747675334", "name": "Powertrain Validation and Test Engineering Intern"}, "start_date": "2014-01-06"}, {"position": {"id": "108703555821060", "name": "Intern"}, "start_date": "2013-06-19", "location": {"id": "105396882827337", "name": "Pasadena, California"}, "end_date": "2013-08-31", "employer": {"id": "8261258923", "name": "Jet Propulsion Laboratory (JPL)"}}, {"description": "http://www.google.com/search?client=safari&rls=en-us&q=define:barback&ie=UTF-8&oe=UTF-8", "end_date": "2011-06-01", "employer": {"id": "148354981878238", "name": "Santikos"}, "location": {"id": "107879769240188", "name": "Tomball, Texas"}, "position": {"id": "208170149275530", "name": "Bartender"}, "start_date": "2008-09-01"}, {"description": "clearing Fancy tables of Fancy plates that once held Fancy foo d but was eaten by Fancy clients.", "end_date": "2009-06-01", "employer": {"id": "1391646277732473", "name": "Lobster Shop Dash"}, "location": {"id": "108537252503370", "name": "Dash Point, Washington"}, "position": {"id": "110448272309606", "name": "Busser"}, "start_date": "2008-06-01"}], "updated_time": "2013-11-29T20:56:44+0000"}

— Reply to this email directly or view it on GitHubhttps://github.com/tschellenbach/Django-facebook/issues/386#issuecomment-29538549 .

tschellenbach avatar Nov 29 '13 23:11 tschellenbach

Hello,

in my case data get stored correctly in the database, I can see them from the admin interface for instance, and I can access them with get_profile instead of profile_or_self.

I can't copy paste my settings right now, I will do that as soon as i can.

marcoforlin avatar Dec 05 '13 08:12 marcoforlin