Here are the examples of the python api django.forms.NumberInput taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
View Complete Implementation : forms.py
Copyright MIT License
Author : lukasvinclav
Copyright MIT License
Author : lukasvinclav
def __init__(self, *args, **kwargs):
name = kwargs.pop('name')
super().__init__(*args, **kwargs)
self.fields[name] = forms.FloatField(label='', required=False,
widget=forms.NumberInput(attrs={'placeholder': _('Value')}))
3
View Complete Implementation : forms.py
Copyright MIT License
Author : lukasvinclav
Copyright MIT License
Author : lukasvinclav
def __init__(self, *args, **kwargs):
self.name = kwargs.pop('name')
super().__init__(*args, **kwargs)
self.fields[self.name + '_from'] = forms.FloatField(label='', required=False,
widget=forms.NumberInput(attrs={'placeholder': _('From')}))
self.fields[self.name + '_to'] = forms.FloatField(label='', required=False,
widget=forms.NumberInput(attrs={'placeholder': _('To')}))
3
View Complete Implementation : test_decimalfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_decimalfield_widget_attrs(self):
f = DecimalField(max_digits=6, decimal_places=2)
self.astertEqual(f.widget_attrs(Widget()), {})
self.astertEqual(f.widget_attrs(NumberInput()), {'step': '0.01'})
f = DecimalField(max_digits=10, decimal_places=0)
self.astertEqual(f.widget_attrs(NumberInput()), {'step': '1'})
f = DecimalField(max_digits=19, decimal_places=19)
self.astertEqual(f.widget_attrs(NumberInput()), {'step': '1e-19'})
f = DecimalField(max_digits=20)
self.astertEqual(f.widget_attrs(NumberInput()), {'step': 'any'})
f = DecimalField(max_digits=6, widget=NumberInput(attrs={'step': '0.01'}))
self.astertWidgetRendersTo(f, '<input step="0.01" name="f" type="number" id="id_f" required>')
3
View Complete Implementation : test_floatfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_floatfield_widget_attrs(self):
f = FloatField(widget=NumberInput(attrs={'step': 0.01, 'max': 1.0, 'min': 0.0}))
self.astertWidgetRendersTo(
f,
'<input step="0.01" name="f" min="0.0" max="1.0" type="number" id="id_f" required>',
)