title: How to make a PATCH request using DJANGO REST framework
body: <p>I am not very experience with Django REST framework and have been trying out many things  but can not make my PATCH request work.</p>
  
  <p>I have a Model serializer. This is the same one I use to add a new entry and ideally I Would want to re-use when I update an entry.</p>
  
  <pre class="lang-py prettyprint-override"><code>class TimeSerializer(serializers.ModelSerializer):
      class Meta:
          model = TimeEntry
          fields = ('id', 'project', 'amount', 'description', 'date')
  
      def __init__(self, user, *args, **kwargs):
          # Don't pass the 'fields' arg up to the superclass
          super(TimeSerializer, self).__init__(*args, **kwargs)
          self.user = user
  
      def validate_project(self, attrs, source):
          """
          Check that the project is correct
          """
          .....
  
      def validate_amount(self, attrs, source):
          """
          Check the amount in valid
          """
          .....
  </code></pre>
  
  <p>I tried to use a class based view :</p>
  
  <pre class="lang-py prettyprint-override"><code>class UserViewSet(generics.UpdateAPIView):
      """
      API endpoint that allows timeentries to be edited.
      """
      queryset = TimeEntry.objects.all()
      serializer_class = TimeSerializer
  </code></pre>
  
  <p>My urls are:</p>
  
  <pre class="lang-py prettyprint-override"><code>url(r'^api/edit/(?P&lt;pk&gt;\d+)/$', UserViewSet.as_view(), name='timeentry_api_edit'),
  </code></pre>
  
  <p>My JS call is:</p>
  
  <pre class="lang-js prettyprint-override"><code>var putData = { 'id': '51', 'description': "new desc" }
  $.ajax({
      url: '/en/hours/api/edit/' + id + '/',
      type: "PATCH",
      data: putData,
      success: function(data, textStatus, jqXHR) {
          // ....
      }
  }
  </code></pre>
  
  <p>In this case I would have wanted my description to be updated, but  I get errors that the fields are required(for 'project'and all the rest). The validation fails. If add to the AJAX call all the fields it still fails when it haves to retrieve the 'project'.</p>
  
  <p>I tried also to make my own view:</p>
  
  <pre class="lang-py prettyprint-override"><code>@api_view(['PATCH'])
  @permission_classes([permissions.IsAuthenticated])
  def edit_time(request):
  
      if request.method == 'PATCH':
          serializer = TimeSerializer(request.user, data=request.DATA, partial=True)
          if serializer.is_valid():
              time_entry = serializer.save()
          return Response(status=status.HTTP_201_CREATED) 
      return Response(status=status.HTTP_400_BAD_REQUEST) 
  </code></pre>
  
  <p>This did not work for partial update for the same reason(the validation for the fields were failing) and it did not work even if I've sent all the fields. It creates a new entry instead of editing the existing one. </p>
  
  <p>I would like to re-use the same serializer and validations, but I am open to any other suggestions. 
  Also, if someone has a piece of working code (ajax code-> api view-> serializer) would be great.</p>