Chartjs-How to generate bubble chart (Chart.js) using data from database FILTERED by user in Django?

0👍

You can make HTTP POST request instead of GET to pass JSON data to a backend. For example:

$.ajax({
    method: "POST",
    url: endpoint,
    data: {
        "organisation": "organisation_name"
    },
    success: function(data){
        //...... some logic there
    }
})

This would pass data as JSON serialized object to Django view.

And then on the Django view you can deserialize the organisation and filter the model:

import json

def get(self, request, format=None):
    json_data = json.loads(request.body)
    organisation_name = json_data.get("organisation")
    organizations = Opp.objects.filter(name=organisation_name).values()
    data = list(organizations)  
    return Response(data)

Leave a comment