Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

User serializer in django rest framework

from rest_framework import serializers

class PostSerializer(serializers.ModelSerializer):
    user = serializers.PrimaryKeyRelatedField(read_only=True, default=serializers.CurrentUserDefault())
    class Meta:
        model = Post
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #User #serializer #django #rest #framework
ADD COMMENT
Topic
Name
4+3 =