Skip to main content

django-simple-timeseries

Serializes small, simple timeseries to a database with Django. Provides the Timeseries class for manipulating timeseries, and the TimeseriesField custom field type for serializing.

Status: Experimental.

PyPI version PyPI Supported Python Versions Test status

Table of Contents

Example

Define a TimeseriesField on a model:

from django.db import models
from django_simple_timeseries import TimeseriesField


class Appliance(models.Model):
    name = models.CharField(max_length=64)
    temperature = TimeseriesField(
        resolution_seconds=60 * 60,
        max_points=24,
        help_text="Last 24 hours of temperature data",
    )

You can then access Timeseries methods on it:

>>> a = Appliance(name='fridge')
>>> a.temperature.add(23.2)
>>> a.save()
>>> # Wait some time.
>>> a.temperature.add(26.5)
>>> a.save()
>>> print(list(a.temperature.iter_points()))
[
    (datetime(2020, 1, 1, 2, 30, 0, tzinfo=<UTC>), 23.2),
    (datetime(2020, 1, 2, 2, 30, 0, tzinfo=<UTC>), 26.5),
]

Requirements

This package is tested against the latest versions of:

  • Python: 3.12, 3.13, 3.14
  • Django: 4.2, 5.2, 6.0
  • MySQL: 8.0
  • PostgreSQL: 14
  • SQLite: 3.9.0+

All database backends are tested with the latest versions of their drivers. SQLite is also tested on GitHub Actions' latest macOS virtual environment.

Installation

pip install django_simple_timeseries

How it works

Timeseries

The Timeseries class implements a simple vector-like timeseries. Timeseries data is always contiguous.

Internally, all timeseries instances have:

  • .start_time, a datetime.datetime corresponding to the first data point;
  • .data_points, the recorded data points (or y-values); and
  • .resolution, a timedelta which describes the fixed interval between samples.

Samples are added by calling the add() method. The add() method ensures contiguousness with the following policy:

  • If fewer than resolution seconds have elapsed since the most recent sample, the most recent sample is replaced.
  • If more than resolution seconds have elapsed since the last sample, the vector is extended by the appropriate number of samples (time_delta % resolution - 1), each which will be recorded as gaps with the value None.
  • In all cases, the vector is trimmed to no more than max_points samples.

TimeseriesField

TimeseriesField is implemented as, and extends, a JSONField. The Timeseries methods .to_object() and .from_object() serialize a Timeseries instance to and from plain python objects, which the custom field type transparently implements.

Usage Notes

This module is experimental and hasn't been exhaustively tested. It is not intended for large timeseries. Use at your own risk!

API reference

Complete reference documentation for the public classes and methods, generated from the library's docstrings, lives in docs/api.md.

Maintainer notes

See docs/maintainer-notes.md for how releases are cut and published.

Changelog

See CHANGELOG.md.

Release files for django-simple-timeseries 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-timeseries 0.4.0
File Size Uploaded
django_simple_timeseries-0.4.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-simple-timeseries 0.4.0
File Interpreter ABI Platform
django_simple_timeseries-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / django_simple_timeseries-0.4.0.tar.gz

Download URL django_simple_timeseries-0.4.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2433acff8040f1f747476aae3d42e54845f972d128f11edbe5e61522f9e7c905
BLAKE2b-256 checksum
How to use checksums
73a4ca343e9bf007200bd4ccb06f4ca2188ed293f1322d126d9a15a21a9c2f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.

Transparency log

Release files / django_simple_timeseries-0.4.0-py3-none-any.whl

Download URL django_simple_timeseries-0.4.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0a00ddeb90234b2dbd0358ffafd933425a726c16d9c9df84308bfdbaf88c77a
BLAKE2b-256 checksum
How to use checksums
58eb1127c925415843fc916d1d398b5cf76149772ee23066607f6e7455ba2d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page