Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
Getting back property of object in a query list SQLAlchemy

I have a join table called UserServices. Which has a FK of service_id and makes a back ref to a service. Below I get all the userServices in which the id in the route param matches the user_id (another FK) I am then trying to access all the service properties on the all_user_services list.

My current code only returns one dict instead of a list of dicts. What am i doing wrong?

@bp.route('/user/<id>/services', methods=['GET'])
def get_services_from_user(id):
    all_user_services = db_session.query(UserService).filter(UserService.user_id == id).all()

    for service in all_user_services:
        result = service_schema.dump(service.service)
        return jsonify(result)
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You just return on first for iteration. You need to create result list:

dumped = [service_schema.dump(s.service) for s in all_user_services]
return jsonify(dumped)
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda