[Fixed]-How to query in nested foreignKey

1👍

Jus’t don’t… what you’re doing here is basically recreating values or (values_list).

The difference here is that your approach is resolving an entire query lookup which is more costly than it needs to be, so either use the above…

 my_records_queryset.values('firstname', 'lastname', 'place')

or you may wish to look into Django Rest Framework and serializers which could give you more control on what values you get back for your relational fields.

👤Sayse

Leave a comment