ObjectSet#

class ansys.dynamicreporting.core.serverless.base.ObjectSet(_model: type[BaseModel] = None, _obj_set: list[BaseModel] = <factory>, _orm_model: type[Model] = None, _orm_queryset: QuerySet = None, _parent: BaseModel = None)#

Bases: object

Collection wrapper around a queryset of BaseModel objects.

An ObjectSet encapsulates a Django queryset and eagerly materializes it into a list of BaseModel instances. It behaves like a simple list for iteration, indexing, and truth testing, while providing extra helpers such as bulk deletion and value extraction.

Methods

ObjectSet.delete()

Delete all objects in this set from the database.

ObjectSet.values_list(*fields[, flat])

Return a list of tuples of field values for objects in the set.

Attributes

ObjectSet.saved

Whether this object set currently reflects saved ORM rows.

delete()#

Delete all objects in this set from the database.

The individual objects’ BaseModel.delete() methods are called, followed by deletion of any remaining rows via the underlying queryset.

Returns:
int

Number of objects deleted.

property saved#

Whether this object set currently reflects saved ORM rows.

values_list(*fields, flat=False)#

Return a list of tuples of field values for objects in the set.

Parameters:
*fieldsstr

Attribute names to extract from each object.

flatbool, default: False

If True, and exactly one field is requested, return a simple list of values instead of a list of 1-tuples.

Returns:
list

List of tuples of field values, or a flat list of values if flat=True and a single field is requested.

Raises:
ValueError

If flat is True but more than one field name is provided.