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

93
Views
How to add more fields to the return response in django rest framework

I am trying to add more fields to the Response in the django rest framework to send to react frontend.

This works fine

@api_view(('GET',))
def get_status(request, task_id):
    task = current_app.AsyncResult(task_id)

    response_data = ImageSerializer(Image.objects.get(pk=task.get()))

    return Response(response_data.data, status=status.HTTP_201_CREATED)

How can I add the json context below to the Response also?

#How can I add the following to my response too
context = {'task_status': task.status, 'task_id': task.id}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can add the extra data with:

@api_view(('GET',))
def get_status(request, task_id):
    task = current_app.AsyncResult(task_id)

    response_data = ImageSerializer(Image.objects.get(pk=task.get()))
    context = {'task_status': task.status, 'task_id': task.id}

    return Response({**context, **response_data.data}, status=status.HTTP_201_CREATED)
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!