[Answer]-Get data from Django's raw() query function?

1👍

According to me, if I understand the question correctly then the raw() manager method can be used to perform raw SQL queries:

 for p in Person.objects.raw('SELECT * FROM myapp_person'):

According to documentation, this can help: https://docs.djangoproject.com/en/dev/topics/db/sql/

For multi-join:

  SELECT table.id, other_table.name AS name from table join other_table using (id)

and pass that into your table model. Django would then treat the names from other_table as though they were names from table and give your normal table instances. You pass the query to ModelName.objects.raw(query)

👤fscore

Leave a comment