6.1-6.4 JLL--实习日志--filter_box,复选框+basic function

Django下拉菜单实现
本文介绍如何在Django项目中实现自定义下拉菜单功能,并通过实例展示如何设置前端选择框与后端数据交互,同时提供了一种方法来获取模型字段的最大最小值。

150_下拉菜档实现

1.实现dropbox下拉的功能的顺序
1.1 因为这个不是form表单里面的下拉框
ui_setting!
selection_box
1. form-control 下拉菜单在表单里面的时候有一个'下拉菜单保护机制',默认的是浏览器自带的一个比较丑陋的表单并且是不可以进行修改的,所以需要用延迟加载的方式进行重写!

  1. 注意传递的数据的形式,用{A:{‘a’:a,’b’:b,’c’:c ,’d’:d}}可以增加
untable_selection_box = {
    'province':
{
'北海道 HOKKAIDO': u'北海道 HOKKAIDO',
'青森県 AOMORI': u'青森県 AOMORI',
'岩手県 IWATE':u'岩手県 IWATE',
  1. 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), request
functional: 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 values
output: 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
“`

1)普通用户端(全平台) 音乐播放核心体验: 个性化首页:基于 “听歌历史 + 收藏偏好” 展示 “推荐歌单(每日 30 首)、新歌速递、相似曲风推荐”,支持按 “场景(通勤 / 学习 / 运动)” 切换推荐维度。 播放页功能:支持 “无损音质切换、倍速播放(0.5x-2.0x)、定时关闭、歌词逐句滚动”,提供 “沉浸式全屏模式”(隐藏冗余控件,突出歌词与专辑封面)。 多端同步:自动同步 “播放进度、收藏列表、歌单” 至所有登录设备(如手机暂停后,电脑端打开可继续播放)。 音乐发现与管理: 智能搜索:支持 “歌曲名 / 歌手 / 歌词片段” 搜索,提供 “模糊匹配(如输入‘晴天’联想‘周杰伦 - 晴天’)、热门搜索词推荐”,结果按 “热度 / 匹配度” 排序。 歌单管理:创建 “公开 / 私有 / 加密” 歌单,支持 “批量添加歌曲、拖拽排序、一键分享到社交平台”,系统自动生成 “歌单封面(基于歌曲风格配色)”。 音乐分类浏览:按 “曲风(流行 / 摇滚 / 古典)、语言(国语 / 英语 / 日语)、年代(80 后经典 / 2023 新歌)” 分层浏览,每个分类页展示 “TOP50 榜单”。 社交互动功能: 动态广场:查看 “关注的用户 / 音乐人发布的动态(如‘分享新歌感受’)、好友正在听的歌曲”,支持 “点赞 / 评论 / 转发”,可直接点击动态中的歌曲播放。 听歌排行:个人页展示 “本周听歌 TOP10、累计听歌时长”,平台定期生成 “全球 / 好友榜”(如 “好友中你本周听歌时长排名第 3”)。 音乐圈:加入 “特定曲风圈子(如‘古典音乐爱好者’)”,参与 “话题讨论(如‘你心中最经典的钢琴曲’)、线上歌单共创”。 (2)音乐人端(创作者中心) 作品管理: 音乐上传:支持 “无损音频(FLAC/WAV)+ 歌词文件(LRC)+ 专辑封面” 上传,填写 “歌曲信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值