Search code examples
google-app-enginegoogle-cloud-datastoresql-order-bydjango-nonrel

Case-insensitive order_by on GAE using django non-rel


Using google app 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:

  1. Armageddon
  2. Batman
  3. Zoolander
  4. iRobot

How do I get them to do a case-insensitive order_by?

Thanks


Solution

  • You need to denormalize: store a separate property that contains a lower-case version of the title, and sort on that.