7.3-7.5 JLL实习日志-实现DropDownBox的功能
来源:互联网 发布:淘宝自动发号软件 编辑:程序博客网 时间:2024/06/06 03:12
改动下拉框,没有实现这个功能,需要从view 端进行取数据得到新的
重点关注以下这两个函数怎么实现interface 的!
'''def getLabelSetting(request): setting = settings(request) return setting['label_setting']def formFieldLocalisation(Form, request): label_setting_instance = getLabelSetting(request) for field in Form: tag_value = field.label if not containsAny(tag_value, " "): field.label = label_setting_instance[tag_value] return Form
if selection:
for options:
option_label = option.label
option.label = label_setting_instance[option_label]
注意理解 default_label_setting=localisation.data_model_label_interface
为什么改成别的localisation.data_model_label_cn
会报错!
实现一个功能,但是怎么去实现改变form端里面的值呢?使用的标签有很多,现在不知道我在拿到form以后怎么取到<selection>
里面的值并且保留这个变化呢???
def formDropDownBoxlocalisation(Form,request): label_setting_instance =getLabelSetting(request) print label_setting_instance.get('Map') for field in Form: print 'field.label',field.label,field.label_tag,'1',field.id_for_label,'2',field.html_name #if field = #print '2,',Form.fields #a= list(Form.fields['property_form_type_choice'].choices) reason = Form.fields['property_form_type_choice'].choices[0].get() print 'reason',reason reason = dict(Form.fields['property_form_type_choice'].choices) print reason for i in reason: value = label_setting_instance.get(i) Form.fields['property_form_type_choice'].choices[0].get(i)=label_setting_instance.get(i) if j[0] == print i,label_setting_instance.get(i) for j in Form.fields['property_form_type_choice'].choices: if j.key == i #print 'label_setting_instance',label_setting_instance[i] #print 'reason[i]',reason[i] #reason[i]= label_setting_instance.get(i) Form.fields['property_form_type_choice'].choices.get(i) = label_setting_instance.get(i) print Form return Form
函数的完整版代码如下
第一步:label_setting_instance =getLabelSetting(request)
根据request里面的值获得对应的locasation.py的label_setting_instance
这个对象是一个dict类型的,所以取元素的时候,通过get的方式去拿label_setting_instance.get(i)
第二步:实现Form.fields['property_form_type_choice'].choices
获得是一个tuple类型的,从form里面取到名为property_form_type_choice
的field的值,因为是一个下拉框,所以有choices的选项的,
第三步:怎么实现这个保存的功能呢? 我现在可以实现改动但是没有实现保存的效果,改完以后还是不会变化,我觉得还是我对于field.label
,field.value
,field.
def formDropDownBoxlocalisation(Form,request): label_setting_instance =getLabelSetting(request) reason = dict(Form.fields['property_form_type_choice'].choices) print reason for i in reason: print i value = label_setting_instance.get(i) print value #Form.fields['property_form_type_choice'].choices[0]=label_setting_instance.get(i) print '1',Form.choice_type_object return Form
总结:这个功能应该是碰到的最难理解的了,我一开始的时候没有办法去理解怎么通过view 端的formDropDownBoxlocalisation
传过来的request,form
两个参数改变form的值!
- 7.3-7.5 JLL实习日志-实现DropDownBox的功能
- 7.14-7.21 JLL实习日志-DropDownBox Upgrade
- 5.2JLL实习 import 功能的实现
- 5.11 JLL实习日志-实现download功能实现
- 5.10 JLL实习日志-实现upload 功能实现
- 5.12 JLL实习日志-实现download功能实现
- 5.12 JLL实习日志-实现Anjular Js 功能实现
- 5.3 JLL 实习日志
- 5.5 JLL 实习日志
- 5.9 JLL实习日志
- 5.27 JLL--实习日志--
- 6.5 JLL--实习日志
- 7.6-7.7 JLL实习日志-AngularJs的实现+windows下连接数据库
- 6.22-6.27 JLL--实习日志--Ajax+js 端实现
- 6.16-6.19 JLL--实习日志--
- 5.26 JLL--实习日志--Primary_Image+total_setting
- 6.15 JLL--实习日志--SetupNewWorkSpace on cloud9
- 8.29-8.30 JLL实习日志-validate deprecated
- UnityEvent内存泄漏
- deferred/when jQuery 1.5版本以后的一些新方法
- springboot自定义配置文件
- BUFF系统
- PhalApi(π框架)1.40登录授权接口过滤重构
- 7.3-7.5 JLL实习日志-实现DropDownBox的功能
- groovy 闭包
- android 上拉刷新下拉加载
- 疯狂的持续集成之路
- 《将博客搬至CSDN》
- 170702 逆向-调试理论复习
- input交替和css动画animation
- mysql5.7初始随机密码解决问题
- 优化回归测试的三种方法