[Vuejs]-Using treeview to filter data with Rest API (Vue & Django)

0👍

One approach would be to use Q objects or use direct filter lookups for the search query.
For the second one, you need to do something like:

  1. Send queries to backend using query parameters. Eg: base_url?Sports=foo&Competition=bar

  2. Implement the get_queryset method of Event Viewset by using something like:

    def get_queryset(self):
        query = Events.objects.all()
        if self.request.method == 'GET':
            query = query.filter(**dict(self.request.query_params))
    

Please note this is just POC for giving you an idea, not tested code.

Leave a comment