Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.
/ django-unitology Public archive

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

License

Notifications You must be signed in to change notification settings

bashu/django-unitology

Repository files navigation

django-unitology

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

Authored by Basil Shubin, and some great contributors.

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',
)

Update your urls.py file:

urlpatterns += [
    url(r'^unitology/', include('unitology.urls')),
]

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •