0

I am trying to get all the data from a model and its foreign keys and I have a hard time using select_related() and values() or values_list(). I got an Order table who got two foreign keys. I need to query all the data and send it as a JsonResponse. This is the line: Order.objects.select_related('persoana_fizica__persoana_juridica').values() I saw I can write inside values what fields I need, I am looking for a method to select all of them without writing every single one, 'all' didn't worked. Any ideas?

Viorel Andrei Chis
  • 147
  • 2
  • 2
  • 10
  • Does this answer your question? [Output Django queryset as JSON](https://stackoverflow.com/questions/15874233/output-django-queryset-as-json) – narendra-choudhary Apr 29 '20 at 10:22
  • I understand how I can turn data intro JSON, but still, I don't know how to get all data from all foreign keys without writing every single field inside values() – Viorel Andrei Chis Apr 29 '20 at 10:32

0 Answers0