def handle(self, *args, **options):
        # Get all the courses in our database.
        course_list = Course.objects.filter(status=settings.COURSE_AVAILABLE_STATUS)
        
        # Make list on course_id and count.
        courses = {}
        for course in course_list:
            count = course.students.count()
            courses[course.id] = count
    
        # Arrange the biggest to smallest.
        sorted(courses.values())
        
        # Delete all old entries
        try:
            LandpageTopPickCourse.objects.all().delete()
        except LandpageTopPickCourse.DoesNotExist:
            pass
        
        # Pick the top three courses and create our entries here
        index = 1
        max_count = 4
        for course_id in courses.keys():
            if index < max_count:  # Pick top 3 courses.
                course_obj = Course.objects.get(id=course_id)
                LandpageTopPickCourse.objects.create(
                    id=index,
                    course=course_obj,
                )
            index += 1
Function will iterate through all the courses in the database and
dataset/ETHPy150Open AcademicsToday/py-academicstoday/academicstoday_project/landpage/management/commands/topcoursespicking.py/Command.handle