serializers.py
735 Bytes
from django.contrib.auth import password_validation
from rest_framework_json_api import serializers
from rest_framework.serializers import Serializer as DRFSerializer
from usuario.models import Usuario
class UsuarioSerializer(serializers.ModelSerializer):
permisos_usuario = serializers.SerializerMethodField()
class Meta:
model = Usuario
fields = (
'first_name',
'last_name',
'email',
'documento_identidad',
'permisos_usuario',
)
@staticmethod
def get_permisos_usuario(instance):
return instance.get_all_permissions()
included_serializers = {
'organismo': 'organismo.serializers.OrganismoSerializer',
}