Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!