我有一个依赖元组的Django模型.我想知道在Django程序中引用该元组中的常量的最佳实践是什么.例如,在这里,我想将"default=0
"指定为更具可读性且不需要注释的内容.有什么建议吗?
Status = (
(-1, 'Cancelled'),
(0, 'Requires attention'),
(1, 'Work in progress'),
(2, 'Complete'),
)
class Task(models.Model):
status = models.IntegerField(choices=Status, default=0) # Status is 'Requires attention' (0) by default.
编辑:
如果可能的话,我想完全避免使用数字.不知何故,使用字符串"需要注意"会更具可读性.