1 2 3 4 5 6 7 8 9 10 11 | from django.forms.widgets import TextInput
class NumberInput(TextInput):
input_type = 'number'
#Usage
widgets = (
'number_field': NumberInput(attrs={'min': '0', 'max': '10', 'step': '1'}),
)
|
More like this
- Generic model filter from request GET data by genbit 1 year, 9 months ago
- SelectDateWidget by silent1mezzo 2 years, 5 months ago
- Fieldsets for Views by Nad/ 3 years, 4 months ago
- server with debugging backdoor by teepark 4 years, 8 months ago
- Radio widget with labels after inputs by avsd 10 months, 2 weeks ago
Comments
Looks good, I been trying to use this but have had no luck. :-( In my forms.py I have:
from django.forms.extras.widgets import *
from django.forms.widgets import TextInput (also tried .extras)
wine_year_zip = forms.IntegerField( label=u'Year:', widgets = (widget=(NumberInput(attrs={'size': 3} )
and
year = forms.IntegerField( label=u'Year:', 'number_field': NumberInput(attrs={'min': '0', 'max': '10', 'step': '1'})
)
Both have resulted in syntax errors.
Suggestions?
#