[Django] #36842: Blank FloatField validation is not run on django admin and value is lost on edition.

3 views
Skip to first unread message

Django

unread,
Jan 5, 2026, 11:42:52 AMJan 5
to django-...@googlegroups.com
#36842: Blank FloatField validation is not run on django admin and value is lost on
edition.
-------------------------------------+-------------------------------------
Reporter: pawel-steto | Type:
| Uncategorized
Status: new | Component:
| contrib.admin
Version: 6.0 | Severity: Normal
Keywords: admin validation | Triage Stage:
floatfield blank | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hello,

Having the following model and associated admin:

{{{
from django.db import models

class FooBar(models.Model):
float_req = models.FloatField()
float_not_req = models.FloatField(null=True, blank=True)
}}}

{{{
from django.contrib import admin

from .models import FooBar

admin.site.register(FooBar)
}}}

If you:
1. Create an entry with both float fields set
2. In django admin, edit the float_not_req field entering an invalid float
(a string for example)
3. Save the model

No issue is shown, the value of the field is overridden and set to None

But If you do the same for the required float field, a validation error is
raised and the field is not overridden.

I know it is possible to change this behavior overriding the save/clean
logic in django admin but I think this is misleading.

Have a nice day,
Pawel
--
Ticket URL: <https://code.djangoproject.com/ticket/36842>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 5, 2026, 2:54:29 PMJan 5
to django-...@googlegroups.com
#36842: Blank FloatField validation is not run on django admin and value is lost on
edition.
-------------------------------------+-------------------------------------
Reporter: pawel-steto | Owner: Vishy
| Algo
Type: Uncategorized | Status: assigned
Component: contrib.admin | Version: 6.0
Severity: Normal | Resolution:
Keywords: admin validation | Triage Stage:
floatfield blank | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vishy Algo):

* owner: (none) => Vishy Algo
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36842#comment:1>

Django

unread,
Jan 5, 2026, 3:31:14 PMJan 5
to django-...@googlegroups.com
#36842: Blank FloatField validation is not run on django admin and value is lost on
edition.
-------------------------------------+-------------------------------------
Reporter: pawel-steto | Owner: Vishy
| Algo
Type: New feature | Status: closed
Component: contrib.admin | Version: 6.0
Severity: Normal | Resolution: wontfix
Keywords: admin validation | Triage Stage:
floatfield blank | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: => wontfix
* status: assigned => closed
* type: Uncategorized => New feature

Comment:

Thanks for the ticket. Admin widgets have used `type="number"` since
#27199, with the result that nonsense values get cleaned by the browser to
`""`, and thus never make it to Django.

If this is not desired, a
[https://docs.djangoproject.com/en/6.0/topics/forms/#the-template
workaround] is documented (however, and TIL -- `novalidate` has no effect
on `type="number"`, so you workarounds are reduced to just using
`TextWidget`.):

> If your form includes a URLField, an EmailField or any integer field
type, Django will use the url, email and number HTML5 input types. By
default, browsers may apply their own validation on these fields, which
may be stricter than Django’s validation. If you would like to disable
this behavior, set the novalidate attribute on the form tag, or specify a
different widget on the field, like TextInput.

If your proposal is to revert #27199, it would present compatibility
concerns and should be discussed first on the
[https://forum.djangoproject.com/c/internals/5 Forum (internals)].
--
Ticket URL: <https://code.djangoproject.com/ticket/36842#comment:2>
Reply all
Reply to author
Forward
0 new messages