Re: Redefine html properties in widget

2016-04-01 Thread Denis Makarov
class FoodForm(ModelForm): class Meta: model = Foods fields = '__all__' widgets = { 'quantity': NumberInput(attrs={'min': 1}), 'comment': TextInput(), } пятница, 1 апреля 2016 г., 11:47:33 UTC+3 пользователь Denis Makarov написал: > > class Foods(models.Model): > >

Re: Redefine html properties in widget

2016-04-01 Thread Denis Makarov
class Foods(models.Model): def __str__(self): return self.name name = models.CharField(max_length=200) quantity = models.PositiveSmallIntegerField(default=1, validators=[ MinValueValidator(1)]) quandesc = models.CharField(max_length=3, choices=(('Item', 'Qty'), ('Kil

Re: Redefine html properties in widget

2016-03-31 Thread Tim Graham
Some attributes such as IntegerField.min_value need to be customized on the field rather than the widget. This will ensure that validation is also done server-side. (see https://github.com/django/django/blob/f3595b25496691966d4ff858a3b395735ad85a6e/django/forms/fields.py#L278-L285 for example)

Redefine html properties in widget

2016-03-31 Thread Denis Makarov
Hello! I have my own ModelForm with widgets in Meta class. class Meta: model = Foods fields = '__all__' widgets = { 'quantity': NumberInput(attrs={'min': 1, 'max': 10, 'name': "quantity2"}), 'comment': TextInput(), } My quantity field have NumberInput as standard. I want to re