0

我有一个如下所示的列表

 self.glb_data_list = [{'disp_type': '2'}]

我想将此“disp_type”值分配给 wtform 下拉字段“disp_type”。这是我的 wtforms 字段

    disp_type = fields.SelectField(u'Preset Mapping',
                                      choices=[(0, u'Custom'),
                                      (1, u'Loopback'),
                                      (2, u'All_East'),
                                      (3, u'All_Wast'),
                                      (4, u'16_East_16_West'),
                                      (5, u'8_East_8_West'),
                                      (6, u'STM1_East')],
                                    coerce=int, default=0) 

有人可以指导我如何分配

4

1 回答 1

0
self.glb_data_list = {'disp_type': 2}

disp_type = fields.SelectField(u'Preset Mapping',
                                      choices=[(0, u'Custom'),
                                      (1, u'Loopback'),
                                      (2, u'All_East'),
                                      (3, u'All_Wast'),
                                      (4, u'16_East_16_West'),
                                      (5, u'8_East_8_West'),
                                      (6, u'STM1_East')],
                                    coerce=int, default=0) 

disp_type.data = self.glb_data_list['dist_type']
于 2014-08-27T13:36:07.947 回答