Skip to content
Advertisement

Django get data from related model which has the FK

how can i make this queryset:

JavaScript

models

JavaScript

with Property.objects.all() I can see in the returned object that there is a listing_set

let say:

JavaScript

but it brings the entire model, and not the related to property_id;

also tried to get Ota data in serializer with SerializerMethodField and perform a new query to get this info, but decrease performance significantly.

Advertisement

Answer

I think you should use related_name

related_name

JavaScript

and

JavaScript
Advertisement