orm --建表字段--性别选择存储
choices参数说明(models.py--建表.数据库中存入的数据是0/1, 调取数据库可以显示中文女性/男性)
sex_choice = (
(0, '女性'),
(1, '男性'),
)
class Author(models.Model):
name = models.CharField( max_length=32)
age = models.IntegerField()
sex_choice = (
(0, '女性'),
(1, '男性'),
)
sex = models.IntegerField(choices=sex_choice,default=1) #choices关键字固定的

浙公网安备 33010602011771号