summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/fields
diff options
context:
space:
mode:
authorStefano Chiodino <StefanoChiodino@users.noreply.github.com>2018-10-03 00:17:23 +0100
committerTim Graham <timograham@gmail.com>2018-10-02 19:17:23 -0400
commit6de7f9ec60fbdc59797bc21803f16260bd203f04 (patch)
treeaf6012d5445e55b6b42e1dc3625e8c8e43c641b6 /django/contrib/postgres/fields
parentbc7e288ca9554ac1a0a19941302dea19df1acd21 (diff)
Fixed #29598 -- Deprecated FloatRangeField in favor of DecimalRangeField.
Diffstat (limited to 'django/contrib/postgres/fields')
-rw-r--r--django/contrib/postgres/fields/ranges.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/django/contrib/postgres/fields/ranges.py b/django/contrib/postgres/fields/ranges.py
index 0bb914d383..74ba4eb230 100644
--- a/django/contrib/postgres/fields/ranges.py
+++ b/django/contrib/postgres/fields/ranges.py
@@ -10,7 +10,8 @@ from .utils import AttributeSetter
__all__ = [
'RangeField', 'IntegerRangeField', 'BigIntegerRangeField',
- 'FloatRangeField', 'DateTimeRangeField', 'DateRangeField',
+ 'DecimalRangeField', 'DateTimeRangeField', 'DateRangeField',
+ 'FloatRangeField',
]
@@ -100,7 +101,23 @@ class BigIntegerRangeField(RangeField):
return 'int8range'
+class DecimalRangeField(RangeField):
+ base_field = models.DecimalField
+ range_type = NumericRange
+ form_field = forms.DecimalRangeField
+
+ def db_type(self, connection):
+ return 'numrange'
+
+
class FloatRangeField(RangeField):
+ system_check_deprecated_details = {
+ 'msg': (
+ 'FloatRangeField is deprecated and will be removed in Django 3.1.'
+ ),
+ 'hint': 'Use DecimalRangeField instead.',
+ 'id': 'fields.W902',
+ }
base_field = models.FloatField
range_type = NumericRange
form_field = forms.FloatRangeField