from rest_framework import serializers
from Auth.models import Profile
from GestionMessagerie.models import Messagerie

class MessageSerializer(serializers.ModelSerializer):
    destinataire_profil = serializers.SerializerMethodField()
    emetteur_profil = serializers.SerializerMethodField()
    class Meta:
        model = Messagerie
        fields = '__all__'
    
    def get_destinataire_profil(self, obj):
        return obj.destinataire.email

    def get_emetteur_profil(self, obj):
        return obj.emetteur.email