Answer the question
In order to leave comments, you need to log in
What code should be written to display an error, this is not a number, my version does not work?
forms.py
def clean_price(self):
price = self.cleaned_data['price']
if price < 1:
raise ValidationError('Цена не может быть ниже 1')
elif not isinstance(price, int):
raise ValidationError('Это не число!')
return price
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question