我想從模型中的用戶到一個觀點,但是我不斷收到一個錯誤類型:Django的Allauth - int()函數的參數必須是字符串或數字,而不是「ReverseSingleRelatedObjectDescriptor」
類型錯誤 - int()函數的參數必須是字符串或數字,而不是「ReverseSingleRelatedObjectDescriptor」
當我到了用戶我有以下幾點: django.db.models.fields.related.ReverseSingleRelatedObjectDescriptor對象在0x7f4a15299590
Models.py
@python_2_unicode_compatible
class SocialAccount(models.Model):
user = models.ForeignKey(allauth.app_settings.USER_MODEL)
provider = models.CharField(verbose_name=_('provider'),
max_length=30,
choices=providers.registry.as_choices())
uid = models.CharField(verbose_name=_('uid'),
max_length=app_settings.UID_MAX_LENGTH)
last_login = models.DateTimeField(verbose_name=_('last login'),
auto_now=True)
date_joined = models.DateTimeField(verbose_name=_('date joined'),
auto_now_add=True)
extra_data = JSONField(verbose_name=_('extra data'), default='{}')
class Meta:
unique_together = ('provider', 'uid')
verbose_name = _('social account')
verbose_name_plural = _('social accounts')
def authenticate(self):
return authenticate(account=self)
def __str__(self):
return force_text(self.user)
Views.py
from allauth.socialaccount.models import SocialToken, SocialAccount
def sc(request):
user = SocialAccount.user
token = SocialToken.objects.filter(account__user=user, account__provider='soundcloud')
你能編輯你的問題發佈你的完整stacktrace嗎? –
@ShangWang我應該更新什麼問題? – Juanvulcano