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.
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.
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
Built Distribution
File details
Details for the file django-unitology-0.0.5.tar.gz
.
File metadata
- Download URL: django-unitology-0.0.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dee1d6c25a4f8c8055e22bb4f3f06b42da4476024563dff65e2ef2ba3968657b |
|
MD5 | 850c76e983f4f44dbbeca9d8f727edc8 |
|
BLAKE2b-256 | 5462a79e34e7654cf50f5565842fad2c66253d049aa956f8d5399432f8386101 |
File details
Details for the file django_unitology-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: django_unitology-0.0.5-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c203e2a2251b2a6ce804ba7507afbd800051a13b3100440b3ebb44b49719e80 |
|
MD5 | 1806cd8331f048bd82866a15f15cddfd |
|
BLAKE2b-256 | 6d1a5154e60025e5b883f7f5561d596f41bab71b7c8cee9cbcbfd2b861945d58 |