title: Auto increment an element value when a URL is hit using API
body: <p>I am new to DRF, so apologies if it's a trivial question.</p>
  <p>I want to create an API endpoint to auto-increment the value of a column in the database, whenever a specified URL is hit.</p>
  <p>For instance:</p>
  <p>In the <strong>models.py</strong> file I have:</p>
  <pre class="lang-py prettyprint-override"><code>class User(models.Model):
    name = models.CharField(null=False, blank=False, max_length=250)
    error= models.IntegerField(null=False, blank=False)
  </code></pre>
  <p>How should I write a class-based API View and Function-based API View that whenever the associated URL hits, the value of error increments by 1?</p>
  <p>In the URL the ID of the row should also be passed such as:
  <code>localhost:8000/users/error/&lt;id&gt;</code></p>
  <p>Upon hitting the above URL the value of the error for user 2 should be increased by one.
  The below is the functional view I wrote but, it is not working properly.
  ERROR1: If the URL is hit and the <code>id</code> is not present in the database then also the response is <code>201</code>.</p>
  <pre class="lang-py prettyprint-override"><code>@api_view(['POST'])
  @permission_classes([permissions.IsAuthenticatedOrReadOnly])
  def updateClick(request, uri_id):
  
      p = Url_data.objects.filter(uri_id=uri_id).update(clicks=F('clicks')+1)
      print(&quot;PPPP: &quot;, p)
      url_obj = Url_data.objects.all()
      serializer = ClickSerializer(url_obj, data=request.data)
      if serializer.is_valid():
          serializer.save()
          return Response(serializer.data, status=status.status_201_CREATED)
  
      return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  
  </code></pre>
  <p>Thanks,</p>