#34260: models.FloatField documentation doesn't mention that +inf, -inf, and NaN
are database-dependent.
-------------------------------------+-------------------------------------
Reporter: Matt Cooper | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 4.1
Severity: Normal | Resolution: wontfix
Keywords: floatfield | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):
Yes, sorry Matt — thanks for the hustle, but I have to agree. This is
right into the woods, for something which most users will never hit.
A model and a form:
{{{
from django import forms
from django.db import models
class FloatModel(models.Model):
number = models.FloatField(null=False)
class FloatForm(forms.ModelForm):
class Meta:
model = FloatModel
fields = ['number']
}}}
Then:
{{{
>>> from ticket_34260.models import FloatModel, FloatForm
>>> form = FloatForm({"number":float("inf")})
>>> form.is_valid()
False
>>> form.errors
{'number': ['Enter a number.']}
>>> form = FloatForm({"number":float("nan")})
>>> form.is_valid()
False
>>> form.errors
{'number': ['Enter a number.']}
>>> form = FloatForm({"number":float("-inf")})
>>> form.is_valid()
False
>>> form.errors
{'number': ['Enter a number.']}
}}}
I appreciate you **can** work around the form layer but I think at that
point we come back to Mariusz' ''we cannot document all caveats in Django
docs''.
Likely this ticket will serve folks searching this in the future, so it's
not all for naught.
--
Ticket URL: <https://code.djangoproject.com/ticket/34260#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070185c55d3c1c-4cdea175-2d71-4c0e-8ea6-27a0c7617ba9-000000%40eu-central-1.amazonses.com.