Skip to content
Advertisement

Tag: django

Django Query with 3 tables

I’m hoping I can get a little guidance. I’m trying to return data from 3 related tables in my template. In SQL, this is a simple approach, but the Django requirements have me stumbling. I’d like to display information similar to this: Here are a simplified representation of the models with the relationships defined. Here is my simplified view: And,

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 views.py json ouput Answer You can use ‘FK__COL’ in the values(): Doc reference: https://docs.djangoproject.com/en/4.0/ref/models/querysets/#values

Getting ID instead of Name in list

I am doing CRUD project with foreign keys and I am using serializers.I want to get the Name of the categories,sub categories,color and size instead of thier IDs serializer: models are: below is the insert function show function instead of name of categories subcategories color size etc I am getting id below is how the product_insert looks on webpage where

Advertisement