[Django]-How to sort records in python?

3👍

Use the .order method on the query to have the Google datastore sort your records for you:

qry_obj = db.Query(user_guide).order('ugq_no')

Note that the user_guide object itself gives you access to the query too:

qry_obj = user_guide.all().order('ugq_no')

You can turn the query into a list simply by calling list on it:

all_list = list(qry_obj)

Leave a comment