title: django rest_framework different update based on a model field and user rights
body: <p>django rest-framework </p>
  
  <p>this is a snipnet of my model:</p>
  
  <pre><code>Class myModel(models.Model)
      title = models.CharField(max_length=255,unique=True)
      category = models.CharField(max_length=10, choices=CATEGORY)
      description = models.CharField(max_length=500)
      status = models.CharField(max_length=9, choices=STATUS, default=STATUS[0][0], null=True)
      status_update_information=models.CharField(max_length=2000, blank=True, null=True)
      creator = models.ForeignKey(User,related_name='Mymodel')
      created_at = models.DateTimeField()
      updated_at = models.DateTimeField()
  </code></pre>
  
  <p>the status field can have 3 value: pending, confirmed and rejected.
  Only the owner or the administrator can update the object but I need to insert some constraint:</p>
  
  <ul>
  <li>only the admin can change the status field and  must provide some extra information stored in an other field (status_update_information)</li>
  <li>if the status is confirmed only some fields can be updated ( description )</li>
  <li>if the status is not confirmed the owner can update all field (obviously not status or status_update_information)</li>
  </ul>
  
  <p>I also need to perform other operation when the administratop update the status field (notify the creator) </p>
  
  <p>in order to manage  that I create three different serializer </p>
  
  <p>One for create the model instance </p>
  
  <pre><code> class MyModelSerializer(serializers.ModelSerializer):
      class Meta:
          model = myModel
          read_only_fields = ('creator', 'status', 'created_at','updated_at')
  
      def create(self, validated_data):
          return super(MyModelSerializer, self).create(validated_data)
  
      def update(self, instance, validated_data):
          return super(MyModelSerializer, self).update(instance, validated_data) 
  </code></pre>
  
  <p>One for update the model if the status is confirmed</p>
  
  <pre><code>class MyModelConfirmedUpdateSerializer(serializers.ModelSerializer):
      class Meta:
          model = myModel
          fields =['title',  'description']
  </code></pre>
  
  <p>and one for the adminstrator</p>
  
  <pre><code>class MyModelAdminSerializer(serializers.ModelSerializer):
      class Meta:
          model = myModel
          read_only_fields =('creator', 'created_at', 'updated_at')
  
      def create(self, validated_data):
          return super(MyModelAdminSerializer, self).create(validated_data)
  
      def update(self, instance, validated_data):
          status = validated_data.get('status')
          if status != str(instance.status):
              if not validated_data.get('status_update_reason'):
                  raise serializers.ValidationError(' status update require motivations')
              else:
                  nofitycreator(instance)
          return super(MyModelAdminSerializer, self).update(instance, validated_data)
  </code></pre>
  
  <p>and override the get_serializer_class method of the Apiview </p>
  
  <pre><code>def get_serializer_class(self):
      serializer_class = self.serializer_class
      if self.request.method == 'PUT' or self.request.method == 'PATCH':
          if self.request.user.is_staff or self.request.user.is_superuser:
              serializer_class = MyModelAdminSerializer
          else:
              try:
                  if self.get_object().status == Initiative.STATUS[1][0]:
                      serializer_class = MyModelConfirmedUpdateSerializer
              except:
                  pass
      return serializer_class
  </code></pre>
  
  <p>Is there  some smart solution?</p>
  
  <p>How can handle the partial update of the status field in order to be sure that the status_update_information are provided?</p>