* status: new => closed
* resolution: => invalid
Comment:
Storing `inf`, `-inf`, and `nan` in `FloatField` works for me, I don't see
any protection against them in `models.FloatField`:
{{{#!diff
diff --git a/tests/model_fields/test_floatfield.py
b/tests/model_fields/test_floatfield.py
index 264b5677e9..e3b3fde380 100644
--- a/tests/model_fields/test_floatfield.py
+++ b/tests/model_fields/test_floatfield.py
@@ -1,3 +1,5 @@
+import math
+
from django.db import transaction
from django.test import TestCase
@@ -31,6 +33,16 @@ class TestFloatField(TestCase):
with self.assertRaisesMessage(TypeError, msg):
obj.save()
+ def test_save_inf(self):
+ for value in [float("inf"), math.inf, "inf"]:
+ FloatModel.objects.create(size=value)
+ for value in [float("-inf"), -math.inf, "-inf"]:
+ FloatModel.objects.create(size=value)
+
+ def test_save_nan(self):
+ for value in [float("nan"), math.nan, "nan"]:
+ FloatModel.objects.create(size=value)
+
def test_invalid_value(self):
tests = [
(TypeError, ()),
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34260#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.