Assuming I have this models.py:
class HRSubject(modes.Model):
group = models.ForeignKey(Group, related_name="hrsubjects")
name = models.CharField(max_length=256)
and my serializes are:
class HRSubjectSerializer(ModelSerializer):
group = GroupSerializer(many=False)
class Meta:
model = HRSubject
ok, now i have a model view set for the HRSubject model. I want to be able to perform an update on the group property, replace this group with other one.
Before Update:
{
"id": 1,
"group": {
"id": 1,
"name": "SomeGroup"
},
"name": "Info"
}
After Update:
{
"id": 1,
"group": {
"id": 2,
"name": "SecondGroup"
},
"name": "Info"
}
How can i accomplish this with the wonderful django-rest-framework 3 package?