title: Django rest framework best way to validate POST request parameters
body: <p>When I receive a <code>POST</code> request on a Django REST framework <code>APIView</code> class, I would like to filter/validate the parameters that are passed to prevent them from being modified. For example, for this serializer:</p>
  <pre class="lang-py prettyprint-override"><code>class MediaSerializer(serializers.ModelSerializer):
      class Meta:
          model = Media
          fields = ('id', 'title', 'content', 'url', 'createdByUser', 'karma', 'type', 'issue', 'creationDate', 'updatedDate')
  </code></pre>
  <p>Some parameters such as the <code>id</code>, <code>creationDate</code> or <code>createdByUser</code> shouldn't be modified. So for my class <code>class MediaDetail(APIView)</code> I have:</p>
  <pre class="lang-py prettyprint-override"><code>def validateRequest(self):
          user = self.request.data.get('createdByUser', None)
          karma = self.request.data.get('karma', None)
          creationDate = self.request.data.get('creationDate', None)
  
          if user is not None or karma is not None or creationDate is not None:
              return Response(status=status.HTTP_400_BAD_REQUEST)
  
  @method_decorator(login_required)
  def post(self, request, pk, format=None):
          self.validateRequest()
          media = self.get_object(pk)
          self._throwIfNotMediaAuthor(media, request.user)
  
          serializer = MediaSerializer(media, data=request.data)
  
          if serializer.is_valid():
              # serializer.save()
              return Response(serializer.data)
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  <p>Is there a better way to make this validation? Maybe on the serializer? I couldn't find enough documentation.</p>