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

# history.sources

## Overview

Events that belong to an object's history without a foreign key to the object.

pghistory finds an object's events through foreign keys: the object's own event table, and every
event table with a foreign key to the object's model. A record that names its object some other
way, as workflow's ``ObjectState`` does with a workflow and a plain integer id, is invisible to that
lookup. The app that owns such a record registers a resolver here, so ``vueda.history`` can include
the record's events without importing that app.

## `register_state_events` {#register_state_events}

Register a resolver that names an object's workflow state events.

``resolver(instance)`` returns a ``pghistory.models.Events`` queryset of the object's state
changes, or ``None`` when the object has no state events. History publishes the events it
returns with ``relation: "state"``.

### Signature {#register_state_events-signature}

`register_state_events(resolver)`

#### Parameters {#register_state_events-parameters}

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

### Source {#register_state_events-source}

`server/vueda/history/sources.py:20`

## `state_events_for` {#state_events_for}

Return the state event querysets that every registered resolver names for ``instance``.

### Signature {#state_events_for-signature}

`state_events_for(instance)`

#### Parameters {#state_events_for-parameters}

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

### Source {#state_events_for-source}

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

## Source

`server/vueda/history/sources.py`
