-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
API filter by created, last_updated #3663
Comments
Working code: created = django_filters.DateFilter()
created__gt = django_filters.DateFilter(
field_name='created',
lookup_expr='gte'
)
created__lt = django_filters.DateFilter(
field_name='created',
lookup_expr='lte'
)
last_updated = django_filters.DateTimeFilter()
last_updated__gt = django_filters.DateTimeFilter(
field_name='last_updated',
lookup_expr='gte'
)
last_updated__lt = django_filters.DateTimeFilter(
field_name='last_updated',
lookup_expr='lte'
) Will also create a Pull Request with the changes if accepted. |
I'll point out that if this is implemented, it must be implemented consistently for all models which have these fields (not just within DCIM). This is best done by creating a new class that the applicable existing FilterSets inherit. @struppinet If you're willing to commit to this work I'm happy to assign this issue to you. |
I'm totally with you, just unsure about namings and implementation. How about that?: class ChangeLoggedFilter(django_filters.FilterSet):
created = django_filters.DateFilter()
created__gte = django_filters.DateFilter(
field_name='created',
lookup_expr='gte'
)
created__lte = django_filters.DateFilter(
field_name='created',
lookup_expr='lte'
)
last_updated = django_filters.DateTimeFilter()
last_updated__gte = django_filters.DateTimeFilter(
field_name='last_updated',
lookup_expr='gte'
)
last_updated__lte = django_filters.DateTimeFilter(
field_name='last_updated',
lookup_expr='lte'
)
// example piece
class RackFilter(TenancyFilterSet, CustomFieldFilterSet, ChangeLoggedFilter): |
That looks good! I think it makes sense to have |
Closes #3663: API filter by created, last_updated
Environment
Proposed Functionality
The date fields (created, last_updated) added in Version 2.3.0 should also be filterable.
Use Case
Get a List of all Racks that have been changed > yyyy-mm-dd
Database Changes
none
External Dependencies
none added
The text was updated successfully, but these errors were encountered: