mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #21752 -- Prevented custom widget step attribute to be overwritten
Thanks orcein at gmail.com for the report.
This commit is contained in:
@@ -289,7 +289,7 @@ class FloatField(IntegerField):
|
||||
|
||||
def widget_attrs(self, widget):
|
||||
attrs = super(FloatField, self).widget_attrs(widget)
|
||||
if isinstance(widget, NumberInput):
|
||||
if isinstance(widget, NumberInput) and 'step' not in widget.attrs:
|
||||
attrs.setdefault('step', 'any')
|
||||
return attrs
|
||||
|
||||
@@ -377,7 +377,7 @@ class DecimalField(IntegerField):
|
||||
|
||||
def widget_attrs(self, widget):
|
||||
attrs = super(DecimalField, self).widget_attrs(widget)
|
||||
if isinstance(widget, NumberInput):
|
||||
if isinstance(widget, NumberInput) and 'step' not in widget.attrs:
|
||||
if self.decimal_places is not None:
|
||||
# Use exponential notation for small values since they might
|
||||
# be parsed as 0 otherwise. ref #20765
|
||||
|
||||
Reference in New Issue
Block a user