在…上
django 3
当我需要没有真实数据库(比如mysql)的数据时,我可以使用
m.IntegerChoices
这
CallType
从未如此改变
IntegerChoices
这很合适。
from django.db import models as m
class CallType(m.IntegerChoices):
PULL = 1
PUSH = 2
class BaseCall(models.Model):
class Meta:
db_table = 't_BaseCall'
call_type = m.PositiveSmallIntegerField(
choices=CallType.choices, default=CallType.PULL)
现在我想扩展
呼叫类型
更复杂。
class CallType(m.IntegerChoices):
PULL = {"number":1,"name":"pulling"}
PUSH = {"number":2,"name":"pushing"}
我应该使用什么练习?
我害怕
整数选择
不适合这种情况。