'How to display mongodb data in html table using django

i want to display mongodb data into the html table but the problem is mycode first print all the time field and then print the all the status and then all the level instead of of printing one at a time this is how my MongoDB data is displayed in form of table

my view.py code is as follows

def generate(request):
    a=str(request.POST.get('level'))
    b= request.POST.get('status')
    c=(request.POST.get('startdate'))
    g=datetime.strptime(c,"%Y-%d-%m")
    d=datetime.strftime(g,"%Y/%d/%m")
    e=request.POST.get('enddate')
    h=datetime.strptime(e,"%Y-%d-%m")
    f=datetime.strftime(h,"%Y/%d/%m")
       


    output=run([sys.executable,'C:\\Users\\siddhant\\Desktop\\intern mongo\\indicator\\work\\water.py',a,b,d,f],stdout=PIPE,text=True)
    
    client=pymongo.MongoClient("mongodb://localhost:27017")
    db = client["water"]
    colle= db["waterlevel"]
    
    data_from_db = colle.find({})
    
    return render(request,'result.html',{'task':data_from_db})
    

my result.html page template which display the table is as follows

<div class="table-responsive">
    <table class="table table-striped">
      <thead>
        <tr>
          <th>time</th>
          <th>status</th>
          <th>level</th>
        </tr>
      </thead>
      <tbody>
        {% for  ta in task %}
        <tr>
          <td>{{ ta.time }}</td>
          <td>{{ ta.status }}</td>
          <td>{{ ta.level }}</td> 
            </tr>
            {% endfor %}
      </tbody>
    </table>
  </div>

i want to create a table which display one datetime unit then on status and level value then move to next row please suggest the possible ways it would be very helpful



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source