Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom queryset order error #126

Closed
wayhome opened this issue Jan 16, 2011 · 2 comments
Closed

custom queryset order error #126

wayhome opened this issue Jan 16, 2011 · 2 comments

Comments

@wayhome
Copy link

wayhome commented Jan 16, 2011

I had a class:

class BlogPost(Document):
    title = StringField()
    date = DateTimeField()

    @queryset_manager
    def live_posts(doc_cls, queryset):
        # This may actually also be done by defining a default ordering for
        # the document, but this illustrates the use of manager methods
        return queryset.order_by('-date')

now ,give the follow tests:

>>> from datetime import datetime
 >>> BlogPost(title='1',date=datetime.now()).save()
 >>>  BlogPost(title='2',date=datetime.now()).save()
 >>> BlogPost.live_posts[0].title
... u'2

Well,it's ok.but If I execute it like this:

>>> BlogPost.live_posts()[0].title
... u'1'

the result is not my want.

The same problem occurs in the mumblr,before template render the entry's ordery is ok,but after the template rended it's wrong.

@wayhome
Copy link
Author

wayhome commented Jan 16, 2011

My mongoengine version is 0.4.0

@rozza rozza closed this as completed in b325181 May 19, 2011
@rozza
Copy link

rozza commented May 19, 2011

Thanks youngking - this has been fixed in dev, I've added a regression test, testing the correct behaviour.

mitar referenced this issue in mitar/mongoengine Sep 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants