Answer the question
In order to leave comments, you need to log in
What is the problem with TypeError: object of type 'int' has no len()?
forms.py
class MoneyMarketForm(Form):
want = SelectField('State', choices=[('b', 'buy'), ('s', 'sell')])
currency = SelectField('curency', choices=[('u','USD'),('e','EUR'),('r','RUB')])
total = IntegerField('total', [validators.required(),validators.Length(0, 10000000)])
course = IntegerField('course', [validators.required('Please enter your course'), validators.Length(0, 10000)])
phone = IntegerField('phone', [validators.required(), validators.NumberRange(min=0, max=10)])
city = SelectField('city' , choices=[('c1','city1'),('c2','city2'),('c3','city3'), ('c4', 'city4')])
area = StringField('area', [validators.required(), validators.Length(max=200)])
comment = StringField('cooment', [validators.required(), validators.Length(max=350)])
relevant = IntegerField('relevant',[validators.required(), validators.Length(max=200)])#?
#submint = SubmitField('Send')
pub_date = DateTimeField('Posted Date (mm/dd/yyyy)', validators=[Required()], format='%m/%d/%Y')
Answer the question
In order to leave comments, you need to log in
total = IntegerField('total', [validators.required(),validators.Length(0, 10000000)])
course = IntegerField('course', [validators.required('Please enter your course'), validators.Length(0, 10000)])
#...
relevant = IntegerField('relevant',[validators.required(), validators.Length(max=200)])#?
1. As already mentioned, a string should be used for the phone number. Otherwise, sooner or later you will have to use the + sign or, say, a number starting with 0 - and you have arrived.
2. The django-localflavor app includes a PhoneField field already in place .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question