Integrity error owner_id DRF
<p>I created a simple model API with Django Rest Framework.. For the most part i followed quick start tutorial on DRF site. 
I am accessing it from angular app using Authorization token. Everything works fine except when i wish to make a new post... </p>

<p>This is the error I get <strong><em>null value in column "owner_id" violates not-null constraint</em></strong></p>

<p>This is my code: 
<strong>models.py</strong></p>

<pre><code>class Post(models.Model)
    title = models.CharField(max_length=100, blank=False)
    point = models.PointField(max_length=255, null=True)
    owner = models.ForeignKey('auth.User', related_name='posts')
    active = models.NullBooleanField()
    created = models.DateTimeField(auto_now_add=True)
    expires = models.DateTimeField(blank=True, null=True)
</code></pre>

<p><strong>serializers.py</strong></p>

<pre><code>class PostSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    class Meta:
        model = Post
        fields = ( 'owner', 'id', 'title', 'point', 'active', 'created', 'expires')
</code></pre>

<p><strong>views.py</strong></p>

<pre><code>class PostList(APIView):
    permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

    def post(self, request, format=None):
        serializer = PostSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    def perform_create(self, serializer):
        serializer.save(owner=self.request.user)
</code></pre>

<p>Thanks.</p>