Giter Site home page Giter Site logo

emilsas / django-naturalsortfield Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathforge/django-naturalsortfield

0.0 2.0 1.0 8 KB

Better ordering for Django CharFields.

Home Page: http://pypi.python.org/pypi/django-naturalsortfield

Python 100.00%

django-naturalsortfield's Introduction

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('title')
>>> 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']

django-naturalsortfield's People

Contributors

emilsas avatar

Watchers

 avatar  avatar

Forkers

kysela-petr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.