1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #35117 -- Added support for the hectare unit in Area.

This commit is contained in:
Alexis Athlani
2024-01-15 23:16:12 +01:00
committed by Mariusz Felisiak
parent 6debeac9e7
commit c7e986fc9f
4 changed files with 33 additions and 2 deletions

View File

@@ -347,8 +347,13 @@ class Distance(MeasureBase):
class Area(MeasureBase):
STANDARD_UNIT = AREA_PREFIX + Distance.STANDARD_UNIT
# Getting the square units values and the alias dictionary.
UNITS = {"%s%s" % (AREA_PREFIX, k): v**2 for k, v in Distance.UNITS.items()}
ALIAS = {k: "%s%s" % (AREA_PREFIX, v) for k, v in Distance.ALIAS.items()}
UNITS = {"%s%s" % (AREA_PREFIX, k): v**2 for k, v in Distance.UNITS.items()} | {
"ha": 10000,
}
ALIAS = {k: "%s%s" % (AREA_PREFIX, v) for k, v in Distance.ALIAS.items()} | {
"hectare": "ha",
}
LALIAS = {k.lower(): v for k, v in ALIAS.items()}
def __truediv__(self, other):