Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6585 มุมมอง

Those anyone know how to define a default value in a field?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Jesus Aldana,


You can use default keyword while filed declaration to define default value.


For Ex:-

Here Some default value example for different type of field.


date = fields.Date('Date', default=lambda self: fields.datetime.now()) #Date Field

name = fields.Char('Name', default='New') #Char Field

type_selection = fields.Boolean('Type', default=True) #Boolean Field


Hope it will helps you.

Thanks,

อวตาร
ละทิ้ง