serializers.py 774 B

1234567891011121314151617181920212223242526
  1. from rest_framework import serializers
  2. from access.models import User
  3. class UserSerializer(serializers.ModelSerializer):
  4. class Meta:
  5. model = User
  6. fields = ["uuid","name","email", "password", "created_at"]
  7. extra_kwargs = {'password': {"write_only": True}}
  8. read_only_fields = [
  9. "uuid",
  10. "created_at",
  11. ]
  12. class UserUpdateSerializer(serializers.ModelSerializer):
  13. class Meta:
  14. model = User
  15. fields = ["uuid", "email","name", "gender", "birthdate", "avatar",]
  16. read_only_fields = [
  17. "uuid", "email"
  18. ]
  19. class UserPublicSerializer(serializers.ModelSerializer):
  20. class Meta:
  21. model = User
  22. fields = ["uuid", "email",]
  23. read_only_fields = ["uuid",]