假设我的django模型中有choicefield,它包含多个选项.现在将来,如果我用其他名称(选择)更改现有选项(选项),那么具有该选择(选项)的模型中的现有记录是否也会改变?或者在管理页面中,我需要手动设置新选项吗?
我怎样才能做到这一点?
我有名为 TestResults 的 django 模型
Class TestResults(models)
chemical_name charfield
value floatfield
unit charfield
method charfield
normal_limit charfield
caution_limit charfield
color charfield
Run Code Online (Sandbox Code Playgroud)
现在,
下面的代码将生成油表,其中包含以下字段。
fields = ('Test Name', 'Value', 'Unit', 'Method',
'Normal Limit', 'Caution Limit')
all_oils = [(test.chemical_name, test.value, test.unit, test.method,
test.normal_limit, test.caution_limit)
for test in TestResult.objects.all())]
oil_table = Table([fields] + all_oils
oil_table.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), '#a7a5a5'),
('FONTSIZE', (0, 0), (-1, 0), 6),
('GRID', (0, 0), (-1, -1), 2, '#a7a5a5'),
('FONTSIZE', (0, 0), (-1, -1), 8),
('FONTNAME',(1,1),(1,-1),'Times-Bold')]))
Run Code Online (Sandbox Code Playgroud)
现在我怎样才能为每列提供动态颜色。假设我的 …