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

265
Vistas
GET request in Django Rest framework is not working with filter in the response JSON object

Views.py

class UserPoints(ListAPIView):

 queryset = UserAttributes.objects.all()
 serializer_class = UserPointsSerializer

OR

def get(self, request, pk, format=None):
    UserAttributes = self.get_object(id)
    serializer = UserPointsSerializer(UserAttributes)
    return Response(serializer.data)

Serializers.py

class UserPointsSerializer(serializers.ModelSerializer): username = serializers.Field(source='User')

class Meta:
    model = UserAttributes
    fields = [
        'points',
    ]

I want to get the point associated with a particular user when I send a GET Request with username as a parameter.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You need to call .is_valid() on the serializer

def get(self, request, pk, format=None):
    user_attributes = UserAttribute.objects.get(id=id)
    serializer = UserPointsSerializer(data=user_attributes)
    if serializer.is_valid():
        return Response(serializer.data)
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