Code Monkey home page Code Monkey logo

django-indian-numbers's Introduction

django-indian-numbers

https://travis-ci.org/narenchoudhary/django-indian-numbers.png?branch=master

django-indian-numbers is a reusable Django application for which provides filters for Django templates for formatting numbers in Indian Number System .

Installation

pip install git+https://github.com/narenchoudhary/django-indian-numbers#egg=django-indian-numbers

Usage

To activate filters, add "indian_numbers" to INSTALLED_APPS settings and use {% load indian_numbers_tags %} in template to access filters.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    ...
    ...
    'indian_numbers',
]

Load the indian_numbers_tags template filters library.

{% load indian_numbers_tags %}

Filters

intcomma_indian

Similar to intcomma in django.contrib.humanize app of Django library. It converts a number to a string formatted with commas as per Indian number system. It works for integer, floating-point and string values which can be converted to integers.

Examples:

  • 100000 becomes 1,00,000
  • 1259647552 becomes 1,25,96,47,552
  • 126500.25 becomes 1,26,500
  • -126500 becomes -1,26,500
  • '100000' becomes 1,00,000

floatcomma_indian

It works exactly likes intcomma, except that it preserves decimal places.

Examples:

  • 25 becomes 25.00
  • 121250.6 becomes 1,125.6
  • 25.675 becomes 25.675
  • 126500.25 becomes 1,26,500.25
  • 126500.75 becomes -1,26,500.75

floatword_indian

Converts a large integer number into a friendly text representation. Highest Denomination is used and 2 lower powers are considered for floating points in text representation. Numbers less than 99 are returned without conversion.

Denominations used are: Hundred, Thousand, Lakh, Crore

Examples:

  • 1000 becomes 1 Thousand
  • 15000 becomes 15 Thousands
  • 15600 becomes 15.60 Thousands
  • 100000 becomes 1 Lakh
  • 1125000 becomes 11.25 Lakhs
  • 10000000 becomes 1 Crore
  • 56482485 becomes 5.64 Crore
  • 56482485.25 becomes 5.64 Crores

django-indian-numbers's People

Contributors

narenchoudhary avatar

Watchers

James Cloos avatar  avatar

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.