Django looping through model data but need to pass additional list data

I am posting data from database using Model, which displays fine. But I am now need to pass an additional list (POST.getlist) variable "mylist" along with the model object data, but I dont know how to dynamically loop through it as the "mylist" requires an index number such as "mylist.0", "mylist.1" and so on.

html page

{% for employee in employees %}
    <tr>  
        <td>{{ mylist.X }}</td>
        <td>{{ employee.USER }}</td>  
        <td>{{ employee.MATERIAL }}</td>  
        <td>{{ employee.C }}.....

models.py

from django.db import models

class Materials(models.Model):
    ID = models.AutoField(primary_key=True)
    USER = models.CharField(max_length=30)   
    MATERIAL = models.CharField(max_length=30)   
    C = models.FloatField(max_length=5)
    MN = models.FloatField(max_length=5)
    V = models.FloatField(max_length=5)
    CR = models.FloatField(max_length=5)
    P = models.FloatField(max_length=5)
    S = models.FloatField(max_length=5)
    AL = models.FloatField(max_length=5)
    CU = models.FloatField(max_length=5)
    SI = models.FloatField(max_length=5)
    MO = models.FloatField(max_length=5)
    NI = models.FloatField(max_length=5)
    CO = models.FloatField(max_length=5)
    NB = models.FloatField(max_length=5)
    TI = models.FloatField(max_length=5)
    W = models.FloatField(max_length=5)
    PB = models.FloatField(max_length=5)
    SN = models.FloatField(max_length=5)
    MG = models.FloatField(max_length=5)
    AS = models.FloatField(max_length=5)
    ZR = models.FloatField(max_length=5)
    B = models.FloatField(max_length=5)
    FE = models.FloatField(max_length=5)

    class Meta:
      db_table = "materials"

view.py

def selection(request):
        current_user = request.user
        boxlist = request.POST.getlist('selectbox')
        weightlist = request.POST.getlist('weight')
        mylist = list(filter(None, weightlist))
        employees = Materials.objects.filter(USER=current_user, ID__in=boxlist)
            
        return render(request,"selection.html",{'employees':employees, 'mylist':mylist}) 
Back to Top