---
url: "https://vueda.dev/v3/reference/api/py/vueda.history.revision.md"
title: "history.revision"
---

# history.revision

## Overview

The per-object revision token.

``object_revision`` answers one question: is the copy of this object I hold still the current one.
It is the object's newest event identifier, and it shares the form of the identifiers the history
response publishes, so a client compares the token it holds against an event's own identifier
directly rather than learning a second concept.

Nothing enforces the token on write. It exists so a later conflict-detection feature has a
primitive to build on.

## Classes

- [ObjectRevisionField](/v3/reference/api/py/vueda.history.revision/ObjectRevisionField.md)

## `annotate_object_revision` {#annotate_object_revision}

Annotate the newest event id for each row. A no-op for a model without history.

Applied where the token is serialized rather than on every queryset, following
``annotate_formatted_name``. The subquery matches on the event table's indexed object column.

### Signature {#annotate_object_revision-signature}

`annotate_object_revision(queryset)`

#### Parameters {#annotate_object_revision-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="annotate_object_revision-param-queryset">queryset</span> |  | yes |  |  |

### Source {#annotate_object_revision-source}

`server/vueda/history/revision.py:41`

## `is_tracked` {#is_tracked}

Whether history recorded an event model for this model.

pghistory sets ``pgh_event_model`` on a model it tracks, so this answers the model's history
policy as it actually resolved rather than as it was declared. A proxy inherits the concrete
model's event model, which is where its writes are recorded.

### Signature {#is_tracked-signature}

`is_tracked(model)`

#### Parameters {#is_tracked-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="is_tracked-param-model">model</span> |  | yes |  |  |

#### Returns {#is_tracked-returns}

`bool`

### Source {#is_tracked-source}

`server/vueda/history/revision.py:31`

## `object_revision` {#object_revision}

Return ``instance``'s newest event identifier, or ``None`` when it has none.

``annotate_object_revision`` is the cheaper path for a queryset on its way through a serializer.
This one serves a caller holding one instance, such as a response reporting the revision of the
row it just wrote. It costs one query.

### Signature {#object_revision-signature}

`object_revision(instance)`

#### Parameters {#object_revision-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="object_revision-param-instance">instance</span> |  | yes |  |  |

### Source {#object_revision-source}

`server/vueda/history/revision.py:64`

## Source

`server/vueda/history/revision.py`
