I am working on a dashboard where an admin can be able to retrieve all the data stored in firebase and then perform operations on this data

I have managed to post data in firebase using a django view and i can also retrieve the same data in an html table using a view but finding difficult to update this data with new data.

My code that updates all the nodes in the firebase instead of only one node i know my problem is on how to retrieve a single id to be updated

i have tried several solutions given online such as this one, but the problem has persisted

 this is my deactivate_status.html
    {% extends 'sidebar.html' %}
   {% block body %}

       <div class="container">
           <h4>Home<b> ></b> Deactivated Service Providers</h4>

              <div class="row">
                    <form id="form" method="POST" action = "/deactivate_status">
                                                {% csrf_token %}
                        <table class="table" border="0.5">

                                    <tr style="font-size:larger">

                                        <th>Profile Pic</th>
                                        <th>Take Action</th>

                                     <tr style="font-size:large">
                                        {% for username,telephone,photo,service,status  in combine %}
                                             <div class="container1">
                                                 <td><img src="{{photo}}" style="max-width:20%; max-height:20%;cursor:pointer"
                                               onclick="onClick(this)" class="modal-hover-opacity"></td>
                                             <td> <button class="btn-success" id="try" value="Deactivate" onClick="Reactivate()" name="status">Reactivate</button></tr>
                                        {% endfor %}


<!-- The Modal -->
<div id="modal01" class="modal" onclick="this.style.display='none'">
  <span class="close">&times;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  <div class="modal-content">
    <img id="img01" style="max-width:100%">
   {% endblock %}

        my view.py
        def deactivate_status(request):
            all_ids = 
        StatusIds = []
        for status_id in all_ids:
        AccStatus = []
        for i in StatusIds:
            accstate = db.child('Users').child('AllServiceProviders').shallow().child(i).child('accountStatus').get()
            accstate = accstate.val()
            if accstate=='approved':
        return redirect('index')

Here is my javascript that am trying to use to update the firebase

    var config ={<!-- this is the configuration script that connects to 
 the firebase-->
    'apiKey': "AIzaSyBRoDeZjRdh9KpSm0BvaI33WQVpSlzEJXs",
     'authDomain': "canondashoard.firebaseapp.com",
      'databaseURL': "https://canondashoard.firebaseio.com",
      'projectId': "canondashoard",
      'storageBucket': "canondashoard.appspot.com",
      'messagingSenderId': "632859978103",
      'appId': "1:632859978103:web:9e081934e5446e3a"

      function Reactivate() {
      var database = firebase.database();
      var stateref=database.ref().child('Users').child('AllServiceProviders');
      var key = stateref.push().key;
      var update ={};
      var result=stateref.update(update);

i have not shown you my firebase-real-time-database because it is working fine, i want to update a single node id when i press a deactivate button but not updating all of the nodes at once.

Thanks for your help.

0 Answers