This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Project Description

Fraction display and form fields for Django

Documentation

The full documentation is at https://django-fractions.readthedocs.org.

Quickstart

Install django-fractions:

pip install django-fractions

Add djfractions to settings.INSTALLED_APPS

Then use it in a project:

import djfractions

In templates:

{% load fractions %}
{% display_fraction 1.25 %}

In Forms:

from djfractions.forms import DecimalFractionField
from django import forms

class MyForm(forms.Form):
    a_fraction = DecimalFractionField()

Features

  • Template tag for displaying float and Decimal values as fractions including mixed numbers
  • DecimalFractionField form field which handles input such as “1/4”, “1 1/2”, “1 and 1/2”, and converts to a decimal.Decimal instance

TODO

  • Add unicode_fraction template tag to display the unicode fraction entity if available
  • forms.FloatDecimalField to return a float rather than Decimal
  • forms.SplitFractionWidget for having separate numerator and denominator form fields
  • forms.SplitMixedFractionWidget for handling mixed number fractions with separate fields
  • models.DecimalBackedFractionField() to store a Decimal value but return/accept it as a fraction
  • models.FloatBackedFractionField() to store a Decimal value but return/accept it as a fraction

Cookiecutter Tools Used in Making This Package

  • cookiecutter
  • cookiecutter-djangopackage

History

Current

1.0.0 (2016.12-31)

  • Stop subclassing Django’s DecimalField and duplicate small amounts of code as necessary for db backend compatibility. Too many things need to be handled differently. Main cause of major version bump.
  • Update forms.FractionField to skip over max_digits and decimal_places kwargs which will get passed in by models.fields.DecimalFractionField
  • Add models.fields.DecimalFractionField.formfield() so that a forms.FractionField will be used by default
  • Fix quantity_to_decimal and quantity_to_fraction to strip leading and trailing spaces before pattern matching and converting to a decimal or fraction
  • Allow for leading negative sign with forms.FractionField input values
  • Fix is_fraction() to allow leading negative sign
  • Add max_digits and decimal_places params to DecimalFractionField in test model
  • Additional test cases for models.fields.DecimalFractionField

0.4.0 (2016-08-29)

  • Added djfractions.models.DecimalFractionField which stores fractions.Fraction values as decimals in the dataase.
  • Better usage of tox to test against different Python and Django versions
  • Added testing against Django 1.10

0.3.2 (2015-08-28)

  • Fixed boolean logic for when to coerce values to thirds in in forms.DecimalFractionField and get_fraction_parts()

0.3.1 (2015-08-12)

  • HISTORY.rst typo fixes
  • pypi release version fix

0.3.0 (2015-08-12)

  • Added forms.FractionField which returns fractions.Fraction instances
  • Refactoring of common code with new forms.FractionField
  • Smarter checking for numeric types throughout the code
  • forms.DecimalFractionField.to_python() handles fractions.Fraction values now
  • Fixed bug handling negative numbers in quantity_to_decimal()
  • Added min_value and max_value to forms.DecimalFractionField
  • Made coerce_thirds, limit_denominator, and use_mixed_numbers params to DecimalFractionField proper named parameters and not just kwargs.

0.2.1 (2015-08-06)

  • Fixed typo in usage docs

0.2.0 (2015-08-06)

  • display_fraction template tag output is templated so that its formatting can be changed by users
  • Added new display_improper_fraction template tag to simplify the common case of wanting to only use improper fractions with no whole numbers
  • Added unicode_entity to template context for display_fraction and display_improper_fraction so that the html entity for common fractions may be used rather than <sup> and <sub> tags
  • Refactored lots of code out into smaller, reusable functions
  • Added a bunch of test cases

0.1.0 (2015-08-01)

  • First release on PyPI.
Release History

Release History

1.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_fractions-1.0.0-py2.py3-none-any.whl (14.9 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jan 1, 2017
django-fractions-1.0.0.tar.gz (14.4 kB) Copy SHA256 Checksum SHA256 Source Jan 1, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting