pythondjangomksunit-conversion

Standard Django / python unit conversion package


I've been googling around and looking for a standard way to handle unit conversion (weight, distance, etc..) in Python / Django.

Since it is a very common problem, I'm afraid that I've not been able to find the proper package. (Found several handmade unit conversion questions, but no package).

As far as I know, USA and Thailand are using non metric system, and this also happens in the UK for people (however they officially support the MKS international system).

Is there an existing way of integrating unit conversion with Django LocaleMiddleware, or django_countries packages?


Solution

  • Quick glance shows such Python packages as units.

    As far Django integration, unit conversion is definitely not something django-countries can deal with. It’s also likely outside of the scope of LocaleMiddleware, which is more of a wrapper around gettext. You can look into whether you can add support conversion on gettext level, but I personally doubt it’d be worth the trouble.

    In your position I’d look into defining utility functions and template tags/filters depending on your project’s specific needs, perhaps utilizing the aforementioned units.