We have a tour node with feauted_date
(DateTime
) field, that can also be nullable.
class TourFilter(OrderByMixin):
class Meta:
model = TourModel
fields = {
'featured_date': ['exact', 'lt', 'gt'],
}
class TourNode(DjangoObjectType):
class Meta:
model = TourModel
filter_fields = TourFilter.Meta.fields
interfaces = (relay.Node, )
Currently we use featured_date
for sorting with OrderMixin
, but is there any way to filter them by not null?
You can use isnull
-(doc) lookup as
class TourFilter(OrderByMixin):
class Meta:
model = TourModel
fields = {
'featured_date': ['exact', 'lt', 'gt', 'isnull'],
}