zoukankan      html  css  js  c++  java
  • django crm2

    1.模糊查询

    由于Q的可以传递字符串属性,可以进行拼接__contains 进行搜索

    2.未报名筛选,未报名的存储在models的 enroll_status_choices中,存储的是

    enroll_status_choices = (('signed', "已报名"),
    ('unregistered', "未报名"),
    ('studying', '学习中'),
    ('paid_in_full', "学费已交齐"))

    需要找到元祖对应的字段,在前段用get__signed__display显示

    方法,找到select选择的属性,点击属性的时候讲原有的optiopn 替换成那4个状态,进行change的查询

     1     $("#s1").change(function () {
     2         if ($(this).val() === "status") {
     3             let s1 = `
     4                <select name="q" id="s2">
     5                     <option value="signed">已报名</option>
     6                     <option value="unregistered">未报名</option>
     7                     <option value="studying">学习中</option>
     8                     <option value="paid_in_full">学费已交齐</option>
     9                 </select>
    10             `;
    11             $(this).next().replaceWith(s1)
    12         }
    13     })
    未报名筛选

    3.批量处理

    进行批量处理时,需要将文件与checkbox 写入一个form表单,在循环的文件加入checkbox循环

    运用获取批量处理的value 执行面向对象的反射

    <td><input type="checkbox" name="select_pk_list" value="{{ customer.pk }}"></td>


     1     def post(self,request):
     2         #批量处理
     3         print(request.POST)
     4         func_str=request.POST.get("action")
     5         data=request.POST.getlist("select_pk_list")
     6         if not hasattr(self,func_str):
     7             return  HttpResponse("非法输入")
     8         else:
     9             func=getattr(self,func_str)
    10             queryset=Customer.objects.filter(pk__in=data)
    11             func(request,queryset)
    12             return redirect(request.path)
    13     def patch_delete(self,request,queryset):
    14         queryset.update(sex="male")
    批量处理

    4.添加客户

    通过forms.ModelForm 进行 MODELFORM操作,  引入form  定义form表单

    class CustomerModelForm(forms.ModelForm):

    class=MATE  fields=__all__""  model=Customer

    通过传递form

    form=CustomerModelForm(request.POst)

    在页面上循环取出

    成功返回添加页面

    失败返回添加页面

    5<>

    编辑

    唯一于添加不同的是

    urls 通过re_path进行捕获到主键

    edit_obj=request.POST.get(px=id)

    form=CustomerModelForm(request.POst,instance=edit.obj)

    来区分

    这里若是要返回上一级,则需要额外她在在页面添加一个他要返回的上一级地址,

    因为他只向的是edit1这个标准路由,要去到上一级需要拼接并且存储在返回的编辑标签上

    然后利用redirect重定向 方法为

    path=request.path

    next="?next=%s",%spath

    6>

    公户转私户

    用反射将

    consultant=request.user
    即可


      


    7>
    未报名颜色

    def get_status(self):
    status_color={
    "studying":"green",
    "signed":"#B03060",
    "unregistered":"red",
    "paid_in_full":"blue"
    }
    return mark_safe("<span style='color:white'>%s</span>"%(status_color[self.status],self.get_status_display()))

    在前端传递的是对象,有自己的方法,,可以再models 生成一个方法,让这个方法被调用,返回值就是这个方法的结果

  • 相关阅读:
    POJ 3261 Milk Patterns (求可重叠的k次最长重复子串)
    UVaLive 5031 Graph and Queries (Treap)
    Uva 11996 Jewel Magic (Splay)
    HYSBZ
    POJ 3580 SuperMemo (Splay 区间更新、翻转、循环右移,插入,删除,查询)
    HDU 1890 Robotic Sort (Splay 区间翻转)
    【转】ACM中java的使用
    HDU 4267 A Simple Problem with Integers (树状数组)
    POJ 1195 Mobile phones (二维树状数组)
    HDU 4417 Super Mario (树状数组/线段树)
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/9937205.html
Copyright © 2011-2022 走看看