title: Django Rest Framework setting default PrimaryKeyRelated field value?
body: <p>Django 1.7</p>
  
  <p>DRF 3.3.2</p>
  
  <p>Python 2.7</p>
  
  <p>In my API I want to set a default value for the user field. For example I have a Playlist model and I want to make sure that on create and update the user is always set from request.user.</p>
  
  <p>My first idea was to override the update method in my views, something like this:</p>
  
  <p>views.py</p>
  
  <pre><code>class PlaylistViewSet(viewsets.ModelViewSet):
      serializer_class = PlaylistSerializer
      lookup_field = 'id'
  
      def update(self, request, *args, **kwargs):
          request.POST._mutable = True
          request.POST['user'] = request.user.id
          request.POST._mutable = False
          return super(PlaylistViewSet, self).update(request, *args, **kwargs)
  </code></pre>
  
  <p>This just overrides any POST data for values that I want to be always set. However this feels hacky and I believe there's a better way.</p>
  
  <p><strong>Second solution:</strong></p>
  
  <p>I pass user with my get_serializer method:</p>
  
  <p>views.py</p>
  
  <pre><code>class PlaylistViewSet(viewsets.ModelViewSet):
      serializer_class = PlaylistSerializer
      lookup_field = 'id'
  
      def get_serializer(self, *args, **kwargs):
          kwargs['user'] = self.request.user
          return super(PlaylistViewSet, self).get_serializer(*args, **kwargs)
  </code></pre>
  
  <p>and then I can access it from the serializer init method:</p>
  
  <p>serializers.py</p>
  
  <pre><code>class PlaylistSerializer(serializers.ModelSerializer):
      user = PrimaryKeyRelatedField(allow_null=True, queryset=User.objects.all(), required=False)    
      class Meta:
          model = Playlist
  
      def __init__(self, *args, **kwargs):
          user = kwargs.pop('user')
          # set the value of the user field here
          super(PlaylistSerializer, self).__init__(*args, **kwargs)
  </code></pre>
  
  <p>And this is where I'm stuck. I can't seem to figure out how to set a value for a PrimaryKeyRelated Field. </p>
  
  <p>I access the field with:</p>
  
  <pre><code>self.fields['owner']
  </code></pre>
  
  <p>but I can't access its data or set pk value.</p>