views
ListFilter
Bases: django_filters.Filter
Source code in tasks/views.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
filter_value_fn = filter_value
instance-attribute
__init__(filter_value=lambda x: x, **kwargs)
Source code in tasks/views.py
13 14 15 |
|
filter(qs, value)
Source code in tasks/views.py
20 21 22 23 24 25 26 27 28 29 30 31 |
|
sanitize(value_list)
Source code in tasks/views.py
17 18 |
|
TaskFilter
Bases: django_filters.FilterSet
Source code in tasks/views.py
34 35 36 37 38 39 |
|
state__in = ListFilter(field_name='state')
class-attribute
Meta
Source code in tasks/views.py
37 38 39 |
|
fields = ['state', 'created_at']
class-attribute
model = Task
class-attribute
TaskViewSet
Bases: viewsets.ModelViewSet
API endpoint that allows users to be viewed or edited.
Source code in tasks/views.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
filter_backends = [DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter]
class-attribute
filter_class = TaskFilter
class-attribute
pagination_class = LimitOffsetPagination
class-attribute
queryset = Task.objects.all()
class-attribute
search_fields = ['object_id', 'name', 'state']
class-attribute
serializer_class = TaskSerializer
class-attribute
get_queryset()
Source code in tasks/views.py
53 54 55 56 57 58 59 |
|