[Answered ]-How to retrieve different type of data in django?

1👍

You can get it from database directly (if you’re using postgres), or prepare it yourself from attendances. Just do what’s best for you.

def index(request):
    staffs = staff.objects.all()
    attendances = attendance.objects.all()
    date = datetime.date.today()
    
    
    # unique_dates = list(attendance.objects.all().order_by().values('date').distinct())
    # OR
    # unique_dates = list({a.date for a in atteendances})
    

    return render(request, "salary/index.html", {'staff': staffs, 'attendance': attendances, 'date': date, 'unique_dates': unique_dates})

Leave a comment