0

我正在将 django-social-auth 集成到我现有的应用程序中。到目前为止,我已经完成了所有工作,唯一缺少的是将我的用户模型(实习生)女巫不使用 auth.User 模型集成到 DSA。当我尝试登录时,我收到以下消息:

"UserSocialAuth.user" must be a "Trainee" instance.

这是我的设置:

LINKEDIN_API_KEY = 'my_key'
LINKEDIN_SECRET_KEY = 'my_key'
LINKEDIN_CONSUMER_KEY = LINKEDIN_API_KEY
LINKEDIN_CONSUMER_SECRET = LINKEDIN_SECRET_KEY
LINKEDIN_SCOPE = ['r_basicprofile', 'r_emailaddress', 'r_fullprofile']
LINKEDIN_EXTRA_FIELD_SELECTORS = ['public-profile-url', 'picture-url', 'date-of-birth']


FACEBOOK_APP_ID = os.environ.get('FACEBOOK_APP_ID')
FACEBOOK_API_SECRET = os.environ.get('FACEBOOK_API_SECRET')
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
# FACEBOOK_PROFILE_EXTRA_PARAMS = {'locale': 'en_US'}

AUTHENTICATION_BACKENDS = (
    # '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.vkontakte.VKontakteBackend',
    # 'social_auth.backends.contrib.live.LiveBackend',
    # 'social_auth.backends.contrib.skyrock.SkyrockBackend',
    # 'social_auth.backends.contrib.yahoo.YahooOAuthBackend',
    # 'social_auth.backends.OpenIDBackend',
    'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_CREATE_USERS = False
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
SOCIAL_AUTH_USER_MODEL = 'trainee.Trainee'
SOCIAL_AUTH_PROTECTED_USER_FIELDS = ['email', 'username', 'name']

LOGIN_URL = '/home/'
LOGIN_REDIRECT_URL = '/'
LOGIN_ERROR_URL = '/'

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.user.get_username',
    'social_auth.backends.pipeline.user.create_user',
    'social_auth.backends.pipeline.social.associate_user',
    'social_account.backends.login.extra_data',
    'social_auth.backends.pipeline.social.load_extra_data',
    'social_auth.backends.pipeline.user.update_user_details',
    # 'social_auth.backends.pipeline.associate.associate_by_email',
    'social_account.backends.login.process',
)
4

1 回答 1

0

我删除了现有的 django-social-auth 表并再次运行 syncdb。

于 2012-12-21T21:03:29.533 回答