-
Hey, I'm thinking of migrating to react using this repository. So far it looks so helpful but I haven't found anything yet about Django filters and how I can integrate them into my react code. Is there an example somewhere that I have missed? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I haven't tried django-filter yet, but I think it should work if you define an adapter for Once adapters have been created, you should be able to pass the filter object into a Django Bridge from django_bridge.response import Response
def product_list(request):
f = ProductFilter(request.GET, queryset=Product.objects.all())
return Response(request, 'my-react-component', {'filter': f}) |
Beta Was this translation helpful? Give feedback.
I haven't tried django-filter yet, but I think it should work if you define an adapter for
FilterSet
andFilter
, much like we do for Django forms. The documentation on how that works is here: https://django-bridge.org/docs/python2react/Once adapters have been created, you should be able to pass the filter object into a Django Bridge
Response
and it'll be automatically converted to javascript and passed in to your React components props: