Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
31592 Lượt xem

Hi,

how to limit the number of characters in a field without using any constraint validation, it should give the user the right to enter just ( ex 4 charactere ).

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try using the attribute size,

name = fields.Char(string='Test', size=16)


Ảnh đại diện
Huỷ bỏ
Tác giả

It work just with Type Char, but i want to use it in the Integer type

It worked for me as I was using Char field

Câu trả lời hay nhất

not sure if this will work, but cannot you then limit the max value of the field to 10000 (so it will only allow you to enter values from 0 to 9999)?

not sure how will this work on the negatives... (what's your expectation on how this should work with negatives)


Mat

Ảnh đại diện
Huỷ bỏ