0

当我尝试使用社交身份验证应用程序在 twitter 上进行注册时出现此错误:

TypeError at /login/twitter/ 
issubclass() arg 1 must be a class  

有谁知道是什么原因造成的?我复制了社交身份验证文档中的所有强制性内容,但出现此错误。

完整追溯:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/login/twitter/

Django Version: 1.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'tager_www',
 'fbregister',
 'captcha',
 'django_twilio',
 'social_auth')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in                             get_response
      115. response = callback(request, *callback_args,     **callback_kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django_social_auth-0.7.22-py2.7.egg/social_auth/decorators.py" in wrapper
      26.  redirect)
    File "/usr/local/lib/python2.7/dist-packages/django_social_auth-0.7.22-py2.7.egg/social_auth/backends/__init__.py" in get_backend
      935. get_backends(force_load=True)
    File "/usr/local/lib/python2.7/dist-packages/django_social_auth-0.7.22-                py2.7.egg/social_auth/backends/__init__.py" in get_backends
      914. if issubclass(backend, SocialAuthBackend):

Exception Type: TypeError at /login/twitter/
Exception Value: issubclass() arg 1 must be a class

设置.py:

AUTHENTICATION_BACKENDS = ( 
# 'fbregister.facebook.FacebookBackend',

'tager_www.views.CustomAuthentication',
'django.contrib.auth',
'django.contrib.auth.backends.ModelBackend'
'social_auth.backends.twitter.TwitterBackend',
'social_auth.backends.facebook.FacebookBackend',
'social_auth.backends.google.GoogleOAuthBackend',
'social_auth.backends.google.GoogleOAuth2Backend',
'social_auth.backends.google.GoogleBackend',
'social_auth.backends.yahoo.YahooBackend',
'social_auth.backends.browserid.BrowserIDBackend',
'social_auth.backends.contrib.linkedin.LinkedinBackend',
'social_auth.backends.contrib.disqus.DisqusBackend',
'social_auth.backends.contrib.livejournal.LiveJournalBackend',
'social_auth.backends.contrib.orkut.OrkutBackend',
'social_auth.backends.contrib.foursquare.FoursquareBackend',
'social_auth.backends.contrib.github.GithubBackend',
'social_auth.backends.contrib.vk.VKOAuth2Backend',
'social_auth.backends.contrib.live.LiveBackend',
'social_auth.backends.contrib.skyrock.SkyrockBackend',
'social_auth.backends.contrib.yahoo.YahooOAuthBackend',
'social_auth.backends.contrib.readability.ReadabilityBackend',
'social_auth.backends.contrib.fedora.FedoraBackend',
'social_auth.backends.OpenIDBackend',
'django.contrib.auth.backends.ModelBackend',

)

4

1 回答 1

0

简短的回答

'django.contrib.auth'您应该从中删除AUTHENTICATION_BACKENDS- 它不是后端,而是模块。

异常说明

django-social-auth有一段代码:

for auth_backend in setting('AUTHENTICATION_BACKENDS'):
    mod, cls_name = auth_backend.rsplit('.', 1)
    module = import_module(mod)
    backend = getattr(module, cls_name)

if issubclass(backend, SocialAuthBackend):
    # ....

随着'django.contrib.auth',backend将成为一个模块,而不是一个类。


第二个问题:这只是一个错字——你忘了,after 'django.contrib.auth.backends.ModelBackend'

于 2013-05-02T06:11:49.323 回答