1๐
โ
You can create a new user serializer to use with TeamMemberSerializer
.
user serializer
class UserSerializer2(serializers.ModelSerializer):
class Meta:
model = User
fields = ['first_name', 'last_name', 'email', 'company']
team member serializer
class TeamMemberSerializer(serializers.ModelSerializer):
user = UserSerializer2(read_only=True)
team = TeamSerializer(read_only=True)
team_role = TeamRoleSerializer(read_only=True)
company = CompanySerializer(read_only=True)
class Meta:
model = TeamMember
fields = "__all__"
read_only_fields = ['state', 'created_at', 'updated_at']
required_fields = ['team', 'user', 'team_role']
๐คAlain Bianchini
0๐
I think you can set the exclude
attribute in the UserSerializer
.
class UserSerializer(serializers.ModelSerializer):
...
class Meta:
...
exclude = ('password',)
...
๐คMetalgear
- [Answered ]-How to link to a parametrized urlpattern?
- [Answered ]-How to set environment variable using Django and Python?
- [Answered ]-Can i use django reversion only for Admin or front end as well
Source:stackexchange.com