Skip to main content

Height / Weight fields for Django models & forms with unit conversion

Project description

Custom model fields to store, retrieve and convert measurements of height, weight and more.

Authored by Basil Shubin, and some great contributors.

https://img.shields.io/pypi/v/django-unitology.svg https://img.shields.io/pypi/dm/django-unitology.svg https://img.shields.io/github/license/bashu/django-unitology.svg https://img.shields.io/travis/bashu/django-unitology.svg

Installation

pip install django-unitology

External dependencies

  • jQuery - this is not included in the package since it is expected that in most scenarios this would already be available.

Setup

Add unitology to INSTALLED_APPS:

INSTALLED_APPS += (
    'unitology',
)

When deploying on production server, don’t forget to run:

python manage.py collectstatic

Usage

# models.py

from django.db import models
from django.contrib import admin

from unitology.models import UnitsFieldMixin
from unitology.fields import WeightField, HeightField
from unitology.forms import UnitsFieldFormMixin


class Person(UnitsFieldMixin):

    name = models.CharField(max_length=128)

    weight = WeightField(blank=True, null=True)
    height = HeightField(blank=True, null=True)


class PersonChangeForm(UnitsFieldFormMixin):

    class Meta:
        model = Person


class PersonAdmin(admin.ModelAdmin):
    form = PersonChangeForm


admin.site.register(Person, PersonAdmin)

Please see example application. This application is used to manually test the functionalities of this package. This also serves as a good example.

You need only Django 1.4 or above to run that. It might run on older versions but that is not tested.

License

django-unitology is released under the MIT license.

Project details


Download files

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

Source Distribution

django-unitology-0.0.3.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

django_unitology-0.0.3-py2-none-any.whl (18.2 kB view details)

Uploaded Python 2

File details

Details for the file django-unitology-0.0.3.tar.gz.

File metadata

File hashes

Hashes for django-unitology-0.0.3.tar.gz
Algorithm Hash digest
SHA256 796da59247faa5abb06bb6383f142649010407a63354c50feed7014b1bff4116
MD5 5a17d33badcd6271c567c6d499f691f0
BLAKE2b-256 ff7ce375408658c1b60e23f586ae5aa8e36302cd62bac4752d1980c34e551c5f

See more details on using hashes here.

File details

Details for the file django_unitology-0.0.3-py2-none-any.whl.

File metadata

File hashes

Hashes for django_unitology-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 e46e8ffe0a364cfc854fbfb9c9add7eddd6ccc7db4363c287f651a29a277acc4
MD5 44a8dc1b123c04922d2ab1fc3042f576
BLAKE2b-256 cfe1b9051fb5d8c9f4dbdc1d748557be63e4dc1dd6320bb5678b89f640fd35e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page