[Fixed]-How to organize data after using filter

1👍

colour = request.POST.get('FormColour') #colour = blue 
data_dict = Database.objects.filter(ColourCOL=colour).values('NameCOL', 'AgeCOL', 'NumCOL')
for data in data_dict:
    print(data['NameCOL'], data['AgeCOL'], data['NumCOL'])

You can create a dict out of the retrieved data using values, iterate over it and access the column name from dict.

👤mukul

Leave a comment