Answer the question
In order to leave comments, you need to log in
What needs to be written in order to get an error, it's not a number?
forms.py
def clean(self):
price = self.cleaned_data['price']
availability = self.cleaned_data['availability']
if price < 1:
raise ValidationError('Цена не может быть ниже 1')
elif availability < 1:
raise ValidationError('Количество не должно быть ниже 1')
elif price != int: - вот здесь в условии что нужно прописать
raise ValidationError('Это не число!') -
Answer the question
In order to leave comments, you need to log in
Just start reading the docs already, huh? https://docs.djangoproject.com/en/4.0/ref/forms/fi...
Maybe just prohibit the use of letters and make a field purely for numbers?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question