I have view class given
class eventList(ListAPIView):
queryset = Event.objects.all().filter(is_active=1, is_approved=1)
serializer_class = eventSerialiser
filter_backends = [DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter]
search_fields = ['event_name', 'event_address', 'start_date', 'start_time', 'end_time',
'age_max', 'age_min','event_organizer__name', 'event_type__name',
'event_city__name', 'event_tag__name']
filterset_fields = ['event_name', 'start_date', 'start_time', 'end_date', 'end_time',
'age_max', 'age_min', 'event_organizer', 'event_type', 'event_city',
'event_tag']
ordering_fields = '__all__'
ordering = ['-id']
All filters working fine but how i can get data against date rang start_date
and end_date
This work for me.
double underscore gte is for greater than equal to
double underscore gt is for greater than
double underscore lte is for less than equal to
double underscore lt is for less than
filterset_fields = {
'start_date':['gte', 'lte', 'exact', 'gt', 'lt'],
'id':['exact'],
'event_name':['exact'],
'start_time':['exact'],
'end_date':['exact'],
'end_time':['exact'],
'age_max':['gte', 'lte', 'exact', 'gt', 'lt'],
'age_min':['gte', 'lte', 'exact', 'gt', 'lt'],
'event_organizer__name':['exact'],
'event_type__name':['exact'],
'event_city__name':['exact'],'event_tag__name':['exact']
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With