[PonyORM-list] global name 'desc' is not defined

Alexey Malashkevich alexeymalashkevich at gmail.com
Tue Dec 17 17:08:06 UTC 2013


Looks like you didn't import the desc() function. You can import it either
this way:

    from pony.orm import *

or this way:

    from pony.orm import desc

The first way will import all the necessary functions for working with Pony
ORM, whereas with the second approach you can choose what you import and
what not. Also, if you don't want to import Pony functions into your global
name space you can do this:

    from pony import orm

In this case you can access the desc() function via the orm module:

    transactions = Transaction.select().order_by(orm.
desc(Transaction.created))[:]

Let me know if it worked for you.
Thanks,
Alexey


On Tue, Dec 17, 2013 at 8:34 PM, Guy Jacks <guy.jacks at gmail.com> wrote:

> transactions = Transaction.select().order_by(desc(Transaction.created))[:]
>
> This works without the desc() method but it fails after I wrap
> Transaction.created in desc().
>
> The documentation states that the following should work:
>
> for p in Product.select(lambda p: p.price >
> 100).order_by(desc(Product.price))
>
> Thanks in advance for any pointers.
>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20131217/950905de/attachment.html>


More information about the ponyorm-list mailing list