Search code examples
pythondjango-rest-frameworkdjango-rest-auth

django-rest-auth encoding email/username


I am running in a issue of UPDATING the extended user profile in django-rest-auth library ( here is the library http://django-rest-auth.readthedocs.io/en/latest/introduction.html )

I extended the User with UserProfile:

    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)

Basically I am creating the initial User which consists of (username, email, password), see the attached pic: Registration of User

And then I am trying to update the information of the userProfile, see the pic for update: Userprofile Update

And here we go, when I try to update it says, "Not found", but the user was registered. And then when I look at the email decoding instead of admin@gmail.com, I have the wrong email decoding admin%40gmail.com, I guess this might be the issue why I cannot update the details of the userprofile.


Solution

  • Based on the provided urls.py the issue seems to be in the URL, which the info is sent to: by default viewsets would form URL with pk parameter, which is incremental Django database ID, so the URL would probably look something like /userprofiles/<pk>/ where pk is numeric User or UserProfile ID (depending on which model is used for the viewset) instead of email slug.