order by in Pony ORM

428 Views Asked by At

I try to implement a order by with the attribute "Nachname" in english "surname". But in my try, the object k ist not found.

I do not understanding, how I can use the oder_by in pony orm

sel = select((k.kuId, a.adressid, k.nachname, k.vorname, k.email, k.telefon, a.kunde, a.ort, a.strasse,
                      a.plz, a.land, a.adresszusatz,
                      a.staat, a.art) for a in Adresse for k in Kunde if k.kuId == a.kunde.kuId and a.art == 1
                     ).order_by(lambda: k.nachname )

How I can order my selection by k.nachname?

Greetings niesel

1

There are 1 best solutions below

0
On

Pycharm can't handle the pony orm syntax and higlights the k in order_by(k.nachname) as unknown reference. The answer for my question is:

sel = select((k.kuId, a.adressid, k.nachname, k.vorname, k.email, k.telefon, a.kunde, a.ort, a.strasse,
                      a.plz, a.land, a.adresszusatz,
                      a.staat, a.art) for a in Adresse for k in Kunde if k.kuId == a.kunde.kuId and a.art == 1
                     ).order_by(lambda: k.nachname )