Better ordering for Django CharFields.
Project description
django-naturalsortfield: Better ordering for CharFields. Ignores spaces at the start of a string, does the right thing with integers, scorns the word “the”.
- Example:
>>> from django.db import models >>> from naturalsortfield import NaturalSortField ... >>> class MyModel(models.Model): ... title = models.CharField(max_length=255) ... title_sort = NaturalSortField() ... >>> MyModel.objects.create(title='ABC') >>> MyModel.objects.create(title='XYZ 1') >>> MyModel.objects.create(title='The XYZ 2') >>> MyModel.objects.create(title='XYZ 10') >>> [obj.title for obj.title in MyModel.objects.order_by('title_sort') ['ABC', 'XYZ 1', 'The XYZ 2', 'XYZ 10']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-naturalsortfield-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa9ce334f07d9ceb80476083fec3bc4da4462fbaedce92f6da40c3294d322cbb |
|
MD5 | 354444bc68d7d276db501600a4b19317 |
|
BLAKE2b-256 | a6bc732634935481edc3bac3af0baf689fb791e45bc68dd0344f03cec4a249c1 |