tags:

views:

39

answers:

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 in the value input from user .

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

for example if user input 33 will get the results that last_contact older than 33 day(s)

+1  A: 

See here. Just modify the timedelta() argument appropriately.

Ignacio Vazquez-Abrams
I am sorry Ignacio Vazquez-Abran I don't understand what you want me to do ? :)
python
Look at my method there no no datetime.now() + timedelta(-30), for instance. my method is got the number of day(s) and filter to get the results that older than the input day(s).
python
Hope you will give me more details on this.BTW thanks for your keep track.:)
python