我正在运行django-rest-auth库中更新扩展用户配置文件的问题(这里是库http://django-rest-auth.readthedocs.io/en/latest/introduction.html)
我用UserProfile扩展了User:
class UserProfile(models.Model):
user = models.OneToOneField(User, primary_key=True,
on_delete=models.CASCADE, related_name='userprofile')
platformLanguage = models.TextField(null=True)
mentorApprovalRequest = models.BooleanField(default=False)
approvedAsMentor = models.BooleanField(default=False)
fullName = models.TextField(null=True)
dateOfBirth = models.DateField(null=True)
placeOfBirth = models.TextField(null=True)
bio = models.TextField(null=True)
基本上我创建的初始用户包括(用户名,电子邮件,密码),请参阅附图:Registration of User
然后我试图更新userProfile的信息,请参阅pic更新:Userprofile Update
在这里,当我尝试更新时,我们说,“未找到”,但用户已注册。然后,当我查看电子邮件解码而不是[email protected]时,我的电子邮件解码错误管理员%40gmail.com,我想这可能是我无法更新userprofile详细信息的问题。
根据提供的urls.py,问题似乎在URL中,信息发送到:默认情况下,viewsets将使用pk
参数形成URL,这是增量Django数据库ID,因此URL可能看起来像/userprofiles/<pk>/
其中pk
是数字用户或UserProfile ID(取决于用于视图集的模型)而不是电子邮件slug。