Skip to content
Advertisement

django model.objects.values() return related id instead of title

I want to get Chapter model data as json , i used values() method and it works but it return book id not the book title and i want the book title

models.py

JavaScript

views.py

JavaScript

json ouput

JavaScript

Advertisement

Answer

You can use ‘FK__COL’ in the values():

JavaScript

Doc reference: https://docs.djangoproject.com/en/4.0/ref/models/querysets/#values

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement