0

I'm writing a REST Api using Django and Django REST framework. I have a profile model which countains several attributes and I'm trying to write an update function for the profile. I have problem with two attributes:

attribute1 = models.CharField()
attribute2 = models.IntegerField()

In my update function (in views.py), I first retrieve the profile that's going to be updated:

profile = Profile.objects.get(id=profile_id)

then I update the fields using the get function (so that every field that is not in the request remains the same):

attribute1 = request.DATA.get('attribute1', profile.attribute1)
attribute2 = request.DATA.get('attribute2', profile.attribute2)

The problem I have is that when I create an instance of profile with attribute1 = "Reg" and attribute2 = 1 but when I update another field of the model, attribute1 becomes u\"(u\\'Reg\\',)\" and attribute2 becomes u\"'(1,)'. I don't know where this problem comes from (I have no problem with other fields). Do you have an idea?

Antoine M.
  • 3,631
  • 3
  • 15
  • 20

0 Answers0