1

我正在尝试将 Django-Facebook 与已经将 Django-Userena 用于用户帐户的应用程序集成。但是,当我通过 Facebook 登录时尝试访问“/accounts/edit”时,我无法编辑任何现有信息。但是,如果我通过 Userena 登录,则可以编辑现有信息。谁能帮我理解为什么?我认为我已经遵循了 Django-Facebook 的说明......

模型.py:

class Profile(UserenaBaseProfile, FacebookProfileModel):
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=('user'),
                                related_name='my_profile')
    website = models.URLField(null=True, blank=True)
    zipcode = models.IntegerField(max_length=5, null=True, blank=True)

    def __unicode__(self):
        return self.user.username

    def create_facebook_profile(sender, instance, created, **kwargs):
        if created:
            Profile.objects.create(user=instance)

    post_save.connect(create_facebook_profile, sender=User)

设置.py:

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.static',
    'django.core.context_processors.media',
    'django.core.context_processors.i18n',
    'django.core.context_processors.debug',
    'django_facebook.context_processors.facebook',
    'django.core.context_processors.request',
    'django.contrib.messages.context_processors.messages',
)
AUTH_PROFILE_MODULE = 'myapp.Profile'
AUTHENTICATION_BACKENDS = (
    'userena.backends.UserenaAuthenticationBackend',
    'guardian.backends.ObjectPermissionBackend',
    'django_facebook.auth_backends.FacebookBackend',
    'django.contrib.auth.backends.ModelBackend',
)
FACEBOOK_REGISTRATION_BACKEND = 'django_facebook.registration_backends.UserenaBackend' 
4

0 回答 0