Listing and Retrieving Users
Learn how to list and retrieve the registered users.
We'll cover the following...
User serializer
When we want to fetch user objects from the database, this serializer class takes care of the serialization of those user objects. Let’s create the user serializer class in serializers.py
, as shown below.
Press + to interact
# .. other serializersclass UserSerializer(serializers.ModelSerializer):class Meta:model = Userfields = ["id","email","is_active","is_staff"]
In the code above:
- The
UserSerializer
class inherits fromModelSerializer
so it can map the model fields into this