2009-12-31 8 views
-1
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_filled. 필터 ... 일 이상 django에서?

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

예를 들어, 사용자 입력 (33)이 지난 33 일마다

답변

1

here보기를 last_contact 결과를 얻을 것이다 경우. timedelta() 인수를 적절하게 수정하면됩니다.

+0

죄송합니다. Ignacio Vazquez-Abran 내가 원하는 것을 이해하지 못합니까? :) – kn3l

+0

거기에 내 방법을 봐 아무 datetime.now() + timedelta (-30), 예를 들면. 내 방법은 입력 한 날보다 오래된 결과를 얻으려면 하루의 수와 필터를 가져야합니다. – kn3l

+0

희망에 대해 자세히 알려주세요. 계속 추적 해 주셔서 감사합니다. :) – kn3l

관련 문제