Open leonardoarbache opened 2 years ago
You can use django-mongoengine-filter
with Django Rest Framework Mongoengine
which is based on DRF with support for MongoDB. You still need to pip install django-filters
, and to INSTALLED_APPS.append('django_filters')
.
You have to define the RelatorioFilterSet
class yourself...
import django_mongoengine_filter
class RelatorioFilterSet(django_mongoengine_filter.FilterSet):
class Meta:
model = RelatorioModel
fields = [
'name", # just an example of a string field that should be filterable
]
name = django_mongoengine_filter.StringFilter()
Thanks for an excellent answer, @oussjarrousse. This is worth being mentioned in recipes if properly documented. Feel free to make a PR.
It would be my first experiment with docs. I will give it a try maybe over the weekend
That would be great @oussjarrousse.
I kind forget this PR and forgot to update here haha
I can confirm that this work i use it for years now
I also would like to add that you can use methods and inside it the mongo pipelines. Its awesome :)
There is a way to integrate it with the Django Rest classes ?
I've tried something like this but it just not working. The response always came empty and i can garatee that there's some documents to be returned.