Case-insensitive order_by on GAE using django non-rel
Using google a开发者_开发知识库pp engine and Django non-rel, I'm querying a list of movies and want to order them alphabetically.
movies = Movie.objects.all().order_by("title")
The problem is for any titles that do not start with an uppercase character is not following the same sort pattern.
So if queried these movies and returned them sorted then "iRobot" would not be between Batman and Zoolander:
- Armageddon
- Batman
- Zoolander
- iRobot
How do I get them to do a case-insensitive order_by?
Thanks
You need to denormalize: store a separate property that contains a lower-case version of the title, and sort on that.
Maybe you can use a computed property that returns the lowercase version of your property?
https://developers.google.com/appengine/docs/python/ndb/properties#computed
精彩评论