django-naturalsortfield 0.1

Better ordering for Django CharFields

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update
LICENSE TYPE:
Other/Proprietary License
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
Nathan Reynolds
HOMEPAGE:
github.com
CATEGORY:
ROOT \ Internet \ HTTP (WWW)
django-naturalsortfield is a Django app that provides 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']

Last updated on October 29th, 2011

requirements

#Django CharFields #better ordering #Django #CharFields #ordering #sorting

Add your review!

SUBMIT