Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6016767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:01:50+00:00 2026-05-23T03:01:50+00:00

Using Mongokit with Python. Having some trouble working out get the last n number

  • 0

Using Mongokit with Python. Having some trouble working out get the last n number of records. Not sure of the syntax Python wants here exactly, but I have:

record = collection.find(sort = [{'timestamp': DESCENDING}],limit=10)

Which gives me the error:

Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\flask-0.6-py2.6.egg\flask\app.py", line 874, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Python26\lib\site-packages\flask-0.6-py2.6.egg\flask\app.py", line 864, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "C:\Python26\lib\site-packages\flask-0.6-py2.6.egg\flask\app.py", line 861, in wsgi_app
    rv = self.dispatch_request()
  File "C:\Python26\lib\site-packages\flask-0.6-py2.6.egg\flask\app.py", line 696, in dispatch_reque
st
    return self.view_functions[rule.endpoint](**req.view_args)
  File "E:\My Dropbox\Cranktrain\Blog\crankblog\apps\admin\views.py", line 24, in panel
    record = collection.find(sort = [{'timestamp': DESCENDING}],limit=10)
  File "C:\Python26\lib\site-packages\mongokit-0.5.13.1-py2.6.egg\mongokit\collection.py", line 67,
in find
    return Cursor(self, *args, **kwargs)
  File "C:\Python26\lib\site-packages\mongokit-0.5.13.1-py2.6.egg\mongokit\cursor.py", line 35, in _
_init__
    super(Cursor, self).__init__(*args, **kwargs)
  File "C:\Python26\lib\site-packages\pymongo-1.9-py2.6-win32.egg\pymongo\cursor.py", line 95, in __
init__
    self.__ordering = sort and helpers._index_document(sort) or None
  File "C:\Python26\lib\site-packages\pymongo-1.9-py2.6-win32.egg\pymongo\helpers.py", line 65, in _
index_document
    for (key, value) in index_list:
ValueError: need more than 1 value to unpack

Any help would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:01:50+00:00Added an answer on May 23, 2026 at 3:01 am

    You should give it a [(field, direction), ...] list, not a dict.

    Sorting specifications must necessarily be ordered; dicts are not ordered.

    Not sure that you need to use a list, try just (field, direction).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using PHP, I'd like to convert a string containing a Roman number into its
Using CouchDB 1.0.1. I have DELETEd some documents, then I PUT some other documents
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using JDeveloper , I started developing a set of web pages for a project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.