O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.7 String Case Ordering

Note that when we created our data in Section 3.8, all of the strings for each field met the same capitalization criteria. As Example 3.81 shows, when we created Tag data, the first letter of the name field of the tag was always capitalized, while the slug field was always all lowercase, as discussed in the beginning of the chapter.

Example 3.81: Python Interpreter Code

>>> Tag.objects.values_list('name','slug').order_by('name') [('Django', 'django'),  ('Education', 'education'),  ('Mobile', 'mobile'),  ('Video Games', 'video-games'),  ('Web', 'web')]

It is important to pick a case and stick to it for all values because the case of a string may affect the order of the values. For instance, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required