@classmethod
def get_by_pk(cls, pks, pk='id'):
    """ Get objects by primary key. Can return either a list or
            a single instance depending on if it is passed a list or not
            as input.
        """
    field = getattr(cls, pk)
    if isinstance(pks, list):
        result = cls.query.filter(field.in_(pks)).all()
    else:
        result = cls.query.filter(field == pks).one()
    return result
