I have the following serializer:
class PerfilSerializer(serializers.ModelSerializer):
usuario = UserSerializer()
seguidores = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
looks = LookSerializer(many=True, read_only=True)
colecciones = ColeccionSerializer(many=True, read_only=True)
class Meta:
model = Perfil
fields = ['id','usuario','boutique','tel','tel_fijo','entrg_pais','entrg_dep',
'entrg_ciudad','entrg_direccion','entrg_cp','rmt_pais','rmt_dep',
'rmt_direccion','rmt_ciudad','rmt_cp','num_cc','avatar','descp_armario',
'tipo_ident','cedula_o_nit','propietario_cc','banco','tipo_cc','follow','seguidores',
'notificacion_follow','colecciones']
The variables looks and collections are relationships with two other serializers.
The issue is that I want to show one of the two depending on whether the variable boutique
is True
or False
. In case of True
show colecciones
and in case of False
, show looks
.