Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix queryset for DateRangeFilter when field_path (related field name)… #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion daterange_filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

'''
import copy
import re
import datetime
import django
from django import forms
Expand Down Expand Up @@ -177,7 +178,7 @@ def queryset(self, request, queryset):
filter_params = clean_input_prefix(dict(filter(lambda x: bool(x[1]), self.form.cleaned_data.items())))

# filter by upto included
lookup_upto = self.lookup_kwarg_upto.lstrip(FILTER_PREFIX)
lookup_upto = re.sub('^{}'.format(FILTER_PREFIX), '', self.lookup_kwarg_upto) # Sort of left replace
if filter_params.get(lookup_upto) is not None:
lookup_kwarg_upto_value = filter_params.pop(lookup_upto)
filter_params['%s__lt' % self.field_path] = lookup_kwarg_upto_value + datetime.timedelta(days=1)
Expand Down