I have three related models and want to make a query to get a combination of fields from all three models.
invoice_select = Ordered_item.objects.filter(oi_order = o_id).select_related()
generates the SQL-statement which I can check with the debug_toolbar. The SQL statement contains all fields of the related models.
Sending the result of the query to a html-file with
return render_to_response('invoice_select.html', {'invoice_select':invoice_select}
provides only the the expression which was defined for the Ordered_item model with:
def __unicode__(self):
return u'%s -- %s -- %s' % (self.oi_order, self.oi_pos, self.oi_item)
So the result of the query looks like:
{'invoice_select': [<Ordered_item: 1109231733 -- 01 -- BP-0516-aa>]}
which are exactly the fields defined in the def unicode(self):
What can I do to add more fields to the result of the query? Why do the fields in the SQL not show up in the result of the query ?
Any help will be highly appreciated.