Session: How to Ignore Entity Changes
To indicate that an entity should be ignored when tracking changes,
use the advanced
session ignore_changes_for
method.
Using load
again to retrieve this entity will not initiate a server call.
The entity will still take part in the session, but be ignored when save_changes
is called.
See more here: Disable Entity Tracking
Syntax
def ignore_changes_for(self, entity: object) -> None: ...
Parameter | Type | Description |
---|---|---|
entity | object |
The instance of an entity for which changes will be ignored. |
Example
product = session.load("products/1-A", Product)
session.ignore_changes_for(product)
product.units_in_stock += 1 # this will be ignored for save_changes
session.save_changes()