class AddСurrency(forms.Form):
def __init__(self, server, *args, **kwargs):
super(AddСurrency, self).__init__(*args, **kwargs)
price = forms.DecimalField(required=True, decimal_places=2,
widget=forms.TextInput(attrs={}))
availability = forms.IntegerField(required=True, widget=forms.TextInput(attrs={}))
def clean_price(self):
price = self.cleaned_data['price']
if price > 10000001.00 or price < 0:
raise forms.ValidationError(_('Неверная цена.'))
return price
def clean_availability(self):
availability = self.cleaned_data['availability']
if availability > 10000000 or availability < 0:
raise ValidationError(_('Неверное количество.'))
price = forms.DecimalField(required=True, decimal_places=None, min_value=0, max_value=10000000.00,
widget=forms.TextInput(attrs={}))
price = models.DecimalField(verbose_name='Цена в $', null=True, decimal_places=2, max_digits=10, blank=True)