def METHOD_NAME(min_participants=400, limit=5, fill_in=True):
    today = datetime.datetime.today()
    sub_query = Competition.objects.annotate(num_participants=Count('participants')) \
        .filter(num_participants__gte=min_participants)
    competitions = Competition.objects.filter(published=True) \
       .filter(Q(end_date__gte=today) | Q(end_date=None)) \
       .filter(pk__in=sub_query) \
       .order_by('?') \
       .select_related('creator')[:limit]
    # shuffle works in place, so turn competitions into list and shuffle it by reference
    competitions = list(competitions)
    comp_count = len(competitions)
    if comp_count < limit and fill_in:
        existing_pks = [c.pk for c in competitions]
        random_competitions = Competition.objects.filter(published=True).exclude(pk__in=existing_pks) \
            .annotate(num_participants=Count('participants')) \
            .select_related('creator') \
            .order_by('-num_participants')[:10]
        try:
            # Had to convert to set/list in Py3
            competitions += sample(set(random_competitions), limit - comp_count)
        except ValueError:
            # Eeep! We don't even have $limit competitions to choose from
            competitions += list(random_competitions)
    shuffle(competitions)
    return competitions