django+xadmin 实现分类器

adminx.py

   def get_list_queryset(self,):
        request = self.request
        qs = super(b_store_pass_by_log_Admin, self).get_list_queryset()
        OrderStatus = request.GET.get('OrderStatus', '')
        Archive = request.GET.get('Archive', '')
        InStoreTimeStart = request.GET.get('InStoreTimeStart', '')
        InStoreTimeEnd = request.GET.get('InStoreTimeEnd', '')
        searchList={
            'OrderStatus__icontains': OrderStatus,
            'Archive__icontains': Archive,
            'InStoreTime__lt': InStoreTimeEnd,
            'InStoreTime__gte': InStoreTimeStart,
        }
        sl={}
        for k, v in searchList.items():
            if isinstance(v, list):
                if v:
                    sl[k] = v
            else:
                if v is not None and v.strip() != '':
                    sl[k] = v
        if sl is not None:
            try:
                qs = qs.filter(**sl)
            except Exception as ex:
                messages.error(request, u'请输入正确内容!')
        return qs

配置文件.txt

b_store_pass_by_log
{'id':'1','id_name':'OrderStatus','descri':'订单状态','urlname1':'OrderStatus','defult_value1':"{'待验货':'0','错色':'1','错款':'2','数量错(少货)':'3','错形态':'4','验货完成待入库':'5','没图片':'6','破损':'7','多货':'8','错码':'9','混发':'10','完成入库':'Y','未到货':'N','已删除':'delete','已归档':'archive'}",'value1':'Y','urlname2':'','defult_value2':'','value2':'','selection':3,'isDate':'','startNum':0,'endNum':1,'inputs':'1','model_name':'b_store_pass_by_log'}
{'id':'2','id_name':'Archive','descri':'异常状态','urlname1':'Archive','defult_value1':"{'验货异常待审核':'W','采购待处理':'YW','仓库待处理':'YA','已处理':'YY','盘库实拍待处理':'YN','正常':'N',}",'value1':'','urlname2':'','defult_value2':'','value2':'','selection':3,'isDate':'','startNum':1,'endNum':0,'inputs':'1','model_name':'b_store_pass_by_log'}
{'id':'3','id_name':'InStoreTime','descri':'入库时间','urlname1':'InStoreTimeStart','defult_value1':'2017-01-01','value1':'','urlname2':'InStoreTimeEnd','defult_value2':'2027-12-12','value2':'','selection':'','isDate':1,'startNum':0,'endNum':1,'inputs':'2','model_name':'b_store_pass_by_log'}

你可能感兴趣的:(django+xadmin 实现分类器)