title: Store client IP on model on requests in Django restframework
body: <p>I would like to store my client's Ip in my model in django restframework. I don't know where to put my function and how to store it when a log gets created:</p>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class Loglist(models.Model):
  """This class represents the loglist model."""
  message = JSONField(null=True)
  date_created = models.TimeField(auto_now_add=True)
  client_ip = models.GenericIPAddressField(null=True)
  
  def __str__(self):
      """Return a human readable representation of the model instance."""
      return "{}".format(self.client_ip)
  </code></pre>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>class CreateView(generics.ListCreateAPIView):
      """This class defined the create behaviour of our rest api."""
      queryset = Loglist.objects.all()
      serializer_class = LoglistSerializer
  
      def perform_create(self, serializer):
          serializer.save()
  
  class DetailsView(generics.RetrieveUpdateDestroyAPIView):
      queryset = Loglist.objects.all()
      serializer_class = LoglistSerializer
  </code></pre>
  
  <p><strong>Serializer.py</strong></p>
  
  <pre><code>class LoglistSerializer(serializers.ModelSerializer):
      """Serializer to map the model instance into JSON format."""
  
      class Meta:
          """Meta class to map serializer's fields with the model fields."""
          model = Loglist
          fields = ('id', 'message', 'date_created', 'client_ip')
          read_only_fields = ('date_created', 'client_ip')
  </code></pre>