代码之家  ›  专栏  ›  技术社区  ›  tree em

在django过滤时间早于…天?

  •  -1
  • tree em  · 技术社区  · 15 年前
    def get_filter_result(self, customer_type='',last_contact_filled='', tag_selected='', city_selected=''):
            qdict = {}
            if customer_type != '':
                qdict['type__name'] = customer_type
                qdict['active']=True
            #MY PROBLEM IS HERE get result that older than last_contact_filled day(s)
            if last_contact_filled != '':
                for day_filter in xrange(1,int(last_contact_filled)+1):
                    qdict['last_contact__day']=day_filter
                #qdict['last_contact']=last_contact_query
            if tag_selected != '':
                idtag = tag_selected.split(',')
                qdict['tag__id__in']=idtag
            if city_selected != '':
                idcity = city_selected.split(',')
                qdict['city__id__in']=idcity
            queryset = Customer.objects.filter(**qdict)
    

    上次联系人填写用户输入的值。

    last_contact = forms.IntegerField(widget = forms.TextInput(attrs={'size': '2'}),help_text='day(s)')
    

    1 回复  |  直到 15 年前
        1
  •  1
  •   Community CDub    8 年前

    看见 here . 只需修改 timedelta() 适当地辩论。