If I have two tables, Company and Sales, and I want to display both sets of data in a single list, how would I do this on Google App Engine using GQL?
The models are:
class Company(db.Model):
companyname = db.StringProperty()
companyid = db.StringProperty()
salesperson = db.StringProperty()
class Sales(db.Model):
companyid = db.StringProperty()
weeklysales = db.StringProperty()
monthlysales = db.StringProperty()
The views are:
def company(request):
companys = db.GqlQuery("SELECT * FROM Company")
sales = db.GqlQuery("SELECT * FROM Sales")
template_values = {
'companys' : companys,
'sales' : sales
}
return respond(request, 'list', template_values)
List html includes:
{%for company in companys%}
{% for sale in sales %}
{% ifequal company.companyid sales.companyid %}
{{sales.weeklysales}}
{{sales.monthlysales}}
{% endifequal %}
{% endfor %}
{{company.companyname}}
{{company.companyid}}
{{company.salesperson}}
{%endfor%}
Any help would be greatly appreciated.