I am trying to make models and serializers that allow GET and POST
The GET will allow the client to see a list of all Users, and will show info like first name, last name, etc, but not access_token
However, the POST just needs the access_token and can pull all info like first name, last name, etc from Facebook.
How can I express and code this assymetric nature of get and post in the serializer
serializers.py
class UserSerializer(serializers.HyperlinkedModelSerializer):
"""
User Serializer
"""
class Meta:
model = models.User
fields = ('id', 'username', 'first_name', 'last_name', 'image_url', 'activities', 'url', 'access_token')
views.py
class UserViewSet(viewsets.ModelViewSet):
"""
List all users - this should be taken out as it would never be used in app, and we wont want this as well, as app can only view friend details
Gives details of an user - this should stay
"""
queryset = models.User.objects.all()
serializer_class = UserSerializer