Hi all,
I don't know how to make a GqlQuery that order by a property of the ReferenceProperty.
In this case, I want to get all the Seat but order by the id of the Room
The GqlQuery reference does not allow a join, so how do you approach in this case?
class Room(db.Model):
id = db.IntegerProperty()
dimension = db.StringProperty(multiline=True)
a room has many seats, each with an id
class Seat(db.Model):
id = db.IntegerProperty()
roomId = db.ReferenceProperty(Room)
seats_query = GqlQuery("SELECT * FROM Seat ")
seats = seats_query.fetch(1000)
Alex is right on his point, so I decided not to touch GqlQuery, and tried to play with Django template instead, I have found the solution to sort Seat by Room'id without having to add new field in Seat class.
I put the code here if anyone has interests ;)) Cheers ;))
{% regroup seats|dictsort:"roomId.id" by roomId.id as room_list %}
<ul>
{% for room in room_list %}
<li>Room: {{room.grouper}}
<ul>
{% for item in room.list %}
<li>Seat no: {{item.id}} </li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>