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.
>>> 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, ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.