You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

django-fractions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-fractions

Fraction display and form fields for Django

5.0.0
pipPyPI
Maintainers
1

============================= django-fractions

.. image:: https://badge.fury.io/py/django-fractions.png :target: https://badge.fury.io/py/django-fractions

.. image:: https://github.com/jmichalicek/django-fractions/workflows/Python%20package/badge.svg :target: https://github.com/jmichalicek/django-fractions/actions?query=workflow%3A%22Python+package%22

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

Keywords

django-fractions

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts