def list_pk_encoder(values, instance, field: Field): return [field.db_value(getattr(v, "pk", v), instance) for v in values]
def list_encoder(values, instance, field: Field): """Encodes an iterable of a given field into a database-compatible format.""" return [field.db_value(element, instance) for element in values]