Django-facebook ValueError at / facebook / connect /

时间:2015-11-06 07:14:10

标签: python django facebook facebook-graph-api django-facebook

我是django和我的新手,我正在使用Django-facebook使用Facebook API在我的Applciation中。我按照This Link

中给出的教程进行了操作

我目前正在local.myexampledomain.com和我的Facebook应用程序设置中运行我的应用程序我的网站网址为http://local.myexampledomain.com/

  

我正在运行Django 1.8.4

当我将我的应用程序重定向到http://local.myexampledomain.com/facebook/connect时,我收到此错误:

ValueError at /facebook/connect/
Please specify a Facebook app id and ensure the context processor is enabled
Request Method: GET
Request URL:    http://local.myexampledomain.com/facebook/connect/?attempt=1&code=AQDsXCLiM0W5MlI-yi0HFyg7QKAUOuZJ0gzFi9NisUm9bHuvqcm-SEtYr79gMPydaVXcuoM5_M0p3piYG6TUesfbDniJJVJx8dLeZ8_MOGy7fwJVxsVHIoxIaccrDVyCFWIx5Q3MlRj3FhjzxNRy4V187FPqpxNv2HWWZ_4otP1UYyQqP6fFEg9yyEUbh9s92Ucqx7nErO-k0kQFrLeSYNYr9kVi03QOVeC40k6SdaQXuKnJRv9PaVnr2nEg3eem-St4vhYwojd3_axaVQSLlE7zvWsMTLeLpgERNJnkDB5uVgXzY781QNzpt3tyunulaTPJ--QdX7VBC7tSL2piaA6O
Django Version: 1.8.4
Exception Type: ValueError
Exception Value:    
Please specify a Facebook app id and ensure the context processor is enabled
Exception Location: /usr/local/lib/python2.7/dist-packages/django_facebook/views.py in connect, line 41
Python Executable:  /usr/bin/python
Python Version: 2.7.6
Python Path:    
['/home/webwerks/code/MyApp',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time:    Fri, 6 Nov 2015 06:52:09 +0000

Settings.py

"""
Django settings for MyApp project.

Generated by 'django-admin startproject' using Django 1.8.5.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{mySecretKey}'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_facebook',
    'basic',
    'likes',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'MyApp.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.core.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'django_facebook.context_processors.facebook'
            ],
        },
    },
]

WSGI_APPLICATION = 'MyApp.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

# /dist-packages/django_facebook/views.py

FACEBOOK_APP_ID = '{MyFbAppID}'
FACEBOOK_APP_SECRET = '{MyFbAppSecret}'

AUTHENTICATION_BACKENDS = 'django_facebook.auth_backends.FacebookBackend'
AUTH_USER_MODEL = 'django_facebook.FacebookCustomUser'

0 个答案:

没有答案