title: Django Rest Framework - Set current user on model with unique constraint
body: <p>I have a model that represents a device identifier and I'd like to create a unique constraint on the device identifier and the current user.
  I was passing the user on the save method but I had to remove the constraint and now that I'm trying to write tests the poor code that I wrote becomes difficult to test. How can I write a serializer where I could set the currentuser as default and mantain the unique contrasint on the model.</p>
  
  <p>This is my model</p>
  
  <pre><code>class DeviceIdentifier(models.Model):
      owner = models.ForeignKey(HDSAuthUser, primary_key=True, on_delete=models.CASCADE)
      id_device = models.UUIDField(primary_key=True)
      insert_date = models.DateTimeField(auto_now_add=True)
  </code></pre>
  
  <p>and this is my serializer</p>
  
  <pre><code>class DeviceIdentifierSerializer(serializers.ModelSerializer):
      """
      Device identifier serializer
      """
  
      class Meta:
          model = DeviceIdentifier
          fields = ('id_device', 'owner')
  </code></pre>
  
  <p>and this is my view</p>
  
  <pre><code>class RegisterDevice(CreateAPIView):
      """
      View for registering device for the logged user
      """
      serializer_class = DeviceIdentifierSerializer
  
      def post(self, request, *args, **kwargs):
          obj = DeviceIdentifierSerializer(data=request.data)
          obj.is_valid()
          obj.save(owner=request.user)
  
          return Response(True)
  </code></pre>