Adam Wattis
1 min readNov 2, 2017

--

Hi Tanveer Raihan, I believe this approach should be good with DRF too.

Since this approach uses the post_save signal, your objects will be automatically indexed into ElasticSearch whenever your DRF views save a new object.

To display an object or object list through DRF you should could let ElasticSearch search for the object(s) and then take the pk of that and retrieve those objects from your regular DB. But that seems like an unnecessary way of doing things. Instead, it would be a cleaner solution to return the ElasticSearch JSON directly through an APIView, or via retrieve() and/or list() methods in the ModelViewSet like this example.

Hope I could help!

--

--