未找到Django Facebook Python包所需的auth后端

时间:2015-06-27 06:10:21

标签: python web-applications django-authentication facebook-canvas pythonanywhere

我一直在关注本教程https://blog.pythonanywhere.com/35/ 使用PythonAnywhere的Django Web应用程序创建Facebook Canvas应用程序。 在创建Django Web应用程序时,我被要求选择Python 版。我能够完成教程,它似乎正在工作 对于Python 2没有任何问题,但它不再支持所以我 决定升级到Python 3.4并删除旧的应用程序。我正在使用 django_facebook并将其与pip3.4 install --user一起安装 PythonAnywhere推荐的.local目录,然后通过 教程再次,但当我检查Facebook应用程序时,画布没有 出现。这是我在PythonAnywhere错误日志中找到的:

2015-06-26 18:41:30,191 :Required auth backend django_facebook.auth_backends.FacebookBackend wasnt found
2015-06-26 18:43:20,474 :/home/username/.local/lib/python3.4/site-packages/django_facebook/models.py:66: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
2015-06-26 18:43:20,474 :  logger.warn('Required auth backend %s wasnt found', required)
2015-06-26 18:43:20,474 :
2015-06-26 18:43:20,473 :/home/username/.local/lib/python3.4/site-packages/django_facebook/models.py:66: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('Required auth backend %s wasnt found', required)

2015-06-26 18:43:20,474 :Required auth backend django_facebook.auth_backends.FacebookBackend wasnt found

它说没有找到django_facebook.auth_backends.FacebookBackend,但是 它出现在我的settings.py中:

"""
Django settings for mysite project.

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

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

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

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'                  

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

TEMPLATE_DEBUG = False

AUTH_PROFILE_MODULE = 'django_facebook.FacebookProfile'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                # list if you haven't customized them:
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.core.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'django_facebook.context_processors.facebook',
            ],
        },
    },
]

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
    'django_facebook.context_processors.facebook',
)

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

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',
    'jftapp',
)

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

    'django_facebook.middleware.FacebookCanvasMiddleWare',
)

ROOT_URLCONF = 'mysite.urls'

WSGI_APPLICATION = 'mysite.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.6/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.6/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.6/howto/static-files/

STATIC_URL = '/static/'

FACEBOOK_APP_ID = 'xxxxxxxxxxxxxxx'                       
FACEBOOK_APP_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'                           
FACEBOOK_CANVAS_PAGE = 'https://apps.facebook.com/%s/' % FACEBOOK_APP_ID
FACEBOOK_SCOPE = ['publish_actions']

我已经对此进行了网络搜索,但似乎我是唯一的人 有这个问题。我很早就开始使用Django和网络编程了 我真的想知道是什么导致了这个错误,如果有的话 解决它。

1 个答案:

答案 0 :(得分:3)

installation instructions提到有必要添加AUTH_USER_MODEL设置,我在settings.py中没有看到。您可能错过了其他步骤,但我没有完全检查。