code: def get_queryset_by_group_and_key(self, group, key=None):
          
          if key is None:
              return self.filter_by(group=group)
  
          else:
              return self.filter_by(group=group, key=key)
docs: get queryset