Django未命名模块backendssocial.apps.Django_应用程序.context_处理器

2024-04-20 12:00:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在通过facebook添加身份验证,当我运行本地主机时,终端中出现以下错误:

xx-MacBook-Pro:bookstore xx$ python manage.py runserver
/Library/Python/2.7/site-packages/django/db/models/fields/subclassing.py:22: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
  RemovedInDjango110Warning)

/Library/Python/2.7/site-packages/django/db/models/fields/subclassing.py:22: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
  RemovedInDjango110Warning)

Performing system checks...

/Library/Python/2.7/site-packages/social/apps/django_app/urls.py:12: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got auth). Pass the callable instead.
  name='begin'),

/Library/Python/2.7/site-packages/social/apps/django_app/urls.py:14: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got complete). Pass the callable instead.
  name='complete'),

/Library/Python/2.7/site-packages/social/apps/django_app/urls.py:17: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got disconnect). Pass the callable instead.
  name='disconnect'),

/Library/Python/2.7/site-packages/social/apps/django_app/urls.py:19: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got disconnect). Pass the callable instead.
  'disconnect', name='disconnect_individual'),

/Library/Python/2.7/site-packages/social/apps/django_app/urls.py:19: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
  'disconnect', name='disconnect_individual'),

System check identified no issues (0 silenced).
September 12, 2016 - 19:22:13
Django version 1.9, using settings 'bookstore.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

我猜这篇文章的最后一部分只是简单地说,Django的新版本将有所不同。我也猜上面的部分是说有一个警告导致它。但是,当我实际转到本地主机时,我收到以下错误:

^{pr2}$

当我pip freeze时,我看到python social auth==0.2.7,所以我不确定是什么导致了这一切。在

这是我的一部分设置.py文件:

INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'social.apps.django_app.default',
  'registration',
  'store',
]
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.contrib.messages.context_processors.messages',
            'social.apps.django_app.context_processors.backends'
            'social.apps.django_app.context_processors.login_redirect'
        ],
    },
},
]
WSGI_APPLICATION = 'bookstore.wsgi.application'

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2',
    'django.contrib.auth.backends.ModelBackend'
)
# Registration
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN = True
LOGIN_REDIRECT_URL ='/store/'

# Email settings
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "xx@gmail.com"
EMAIL_HOST_PASSWORD = "xx"
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = "xx@xx.com"

# Social Auth - Facebook
SOCIAL_AUTH_FACEBOOK_KEY = 'xx'
SOCIAL_AUTH_FACEBOOK_SECRET = 'xx'

提前感谢您的帮助!在


Tags: appsdjangopyapppackageslibrarysitesocial
1条回答
网友
1楼 · 发布于 2024-04-20 12:00:49

TEMPLATES变量中缺少一个逗号:

'context_processors': [
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    'social.apps.django_app.context_processors.backends' < - MISSING COMMA
    'social.apps.django_app.context_processors.login_redirect'
],

相关问题 更多 >