6.1-6.4 JLL--实习日志--filter_box,复选框+basic function
来源:互联网 发布:itunes无法连接到网络 编辑:程序博客网 时间:2024/06/16 07:59
150_下拉菜档实现
1.实现dropbox下拉的功能的顺序
1.1 因为这个不是form表单里面的下拉框
ui_setting!
selection_box
1. form-control 下拉菜单在表单里面的时候有一个'下拉菜单保护机制',默认的是浏览器自带的一个比较丑陋的表单并且是不可以进行修改的,所以需要用延迟加载的方式进行重写!
- 注意传递的数据的形式,用{A:{‘a’:a,’b’:b,’c’:c ,’d’:d}}可以增加
untable_selection_box = { 'province':{'北海道 HOKKAIDO': u'北海道 HOKKAIDO','青森県 AOMORI': u'青森県 AOMORI','岩手県 IWATE':u'岩手県 IWATE',
- button 按键自动的跳转 - - 这个是自己犯傻了
是因为在js 那边有一个写了一个跳转的语句
<script type="text/javascript"> $('#a').click(function(e){ e.preventDefault(); var filtervalue= document.getElementById('filter').value; var selectvalue_one = document.getElementById('filter-display'); var index_one = selectvalue_one.selectedIndex; var selectValue_one = selectvalue_one.options[index_one].text; var selectvalue = document.getElementById('insert_value'); var index = selectvalue.selectedIndex; var selectValue_s = selectvalue.options[index].text; console.log(filtervalue+selectValue_s) var url = '/property/search_province/?a='+selectValue_s+'&b='+filtervalue+'&c='+selectValue_one //a = province b ='NameUnicode ' c = selectbox_one url = encodeURI(url); var link = document.getElementById("a"); link.setAttribute('href',url) window.location.href=url }) </script>
5.前端代码,untable_selection_box.province
<div class="col-sm-12" style="padding:0px;0px;0px;-10px;"> <div class="col-sm-2" > <select id="insert_value" class="form-control" > {% for Prefectures in untable_selection_box.province %} <option value='{{ Prefectures }}' id='{{Prefectures}}'>{{Prefectures}}</option> {% endfor %} </select> </div> </div>
6views的函数,直接从ui_setting 引入,不是作为全局变量的形式引入的,ui_setting
```
from ui_setting import module_sets, ui_sets,untable_selection_box
在view函数里面直接传到前端就行了!!
return render_to_response(ui_sets[‘search_property_view’], {‘untable_selection_box’:untable_selection_box,’properties’: properties, ‘message_for_add_result’:message_for_add_result}, context_instance = RequestContext(request))
## Basic function 要求 ##英文版:attribute 类型的实现Django modal get attribute name
def FindRange(object list ,attribute,request):
if not object or object == []:
max = object list[0].attribute
min = object list[0].attribute
for i in object list:
if not no_access():
return 404
else:
if i.attribute >= max:
max = i.attribute
if i.attribute <= min :
min = i.attribute
output.min = min
output.max = max
return output
Add a basic function:parameter: object (which indicates an object elements list, ex. Property List, Availability List, ), attribute (which indicates an specific object attributes, ex. Rent_Warehouse), requestfunctional: 1. no_access cleansing to exclude any element that is not accessible 2. get the largest and smallest values for the parameter attribute in object list. 3. return the valuesoutput: an return object named ‘output’, which has output.max, output.min use basic function above in availability search view to get the min/max rent/area of availability list which would be sent to front-end. Use the value in front-end to achieve dynamic-display of filter range. 1. 设计一个自定义的对象,使用的是class ! 我理解的错误是把class 设计在函数外面 变成了全局变量了! 这个output 类型的对象是需要设计出来的!
class output:
def init(self,max_range,min_range):
self.max_range = No module named loadingmax_range
self.min_range = min_range
2. 获取Django model 中字段的string 类型的名称get_modal函数[获取Django model中的字段名称和字段的类型](http://www.loonapp.com/blog/12/)作用是获得数据库里面已经有的verbose_name 是和field.name 相互对应的,这个
modelobj = apps.get_model(‘horizonforgov’,’Availability’)
for field in modelobj._meta.fields:
fielddic[field.name] = field.name
#返回的是‘charfield’,’textfield’,等这些类型
2.1 No module named loading问题!无法得到get_model 这个函数,我觉得还是有点问题的,为什么没有办法引入呢
try:
from django.db.models.loading import get_model
except ImportError:
from django.apps import app
为了有更加通用的功能,这边判断是什么样的对象,Property还是availablity 对象
if isinstance(objectlist[0],Property):
type_object = ‘Property’
elif isinstance(objectlist[0],Availability):
type_object = ‘Availability’
这边还是没有办法明白为什么要引入get_model 函数?
modelobj = apps.get_model(‘horizonforgov’,type_object)
for field in modelobj._meta.fields:
fielddic[field.name] = field.name #返回的是‘charfield’,’textfield’,等这些类型
attr = fielddic[attribute]
利用__getattribute__函数获得对应对象的属性!!
for i in objectlist:
if not can_access(i,request):
render_to_response(‘no_access.html’)
elif i.getattribute(attr) >= max_range:
max_range = i.getattribute(attr)
elif i.getattribute(attr) <= min_range:
min_range = i.getattribute(attr)
5. gitHub改变秘钥的步骤5.1 确定连接的帐号是谁的
sh -T git@github.com
5.2 创建一个新的密钥
ssh-keygen -t rsa -b 4096 -C “your_email@example.com”
5.3 打开公钥,贴在gitHub上
vim /home/ubuntu/.ssh/id_rsa.pub +Tab
“`
- 6.1-6.4 JLL--实习日志--filter_box,复选框+basic function
- 5.3 JLL 实习日志
- 5.5 JLL 实习日志
- 5.9 JLL实习日志
- 5.27 JLL--实习日志--
- 6.5 JLL--实习日志
- 6.16-6.19 JLL--实习日志--
- 5.26 JLL--实习日志--Primary_Image+total_setting
- 6.15 JLL--实习日志--SetupNewWorkSpace on cloud9
- 7.14-7.21 JLL实习日志-DropDownBox Upgrade
- 8.29-8.30 JLL实习日志-validate deprecated
- 9.1-9. JLL实习日志-未完结
- 6.5 JLL--实习日志--改变数据库结构update+修改下拉框
- 5.4 JLL 实习日志 –form 表单问题
- 5.11 JLL实习日志-实现download功能实现
- 5.10 JLL实习日志-实现upload 功能实现
- 5.12 JLL实习日志-实现download功能实现
- 5.12 JLL实习日志-实现Anjular Js 功能实现
- vue2.0详细目录结构注解
- mysql数据创建用户及授权
- 平衡二叉树的判断
- 单链表反转--java版
- Week Training: 62 Unique Paths
- 6.1-6.4 JLL--实习日志--filter_box,复选框+basic function
- HttpClient使用详解
- 编程第一百天
- 51541327
- 详解单例模式
- 多线程-定时器的概述和使用
- 慕课网学习Python进阶教程,包括(函数式编程、模块、面向对象编程、类的继承、定制类)
- Myeclipse 右上角 outline 图标详解
- Centos 7.3 Install openstack