Skip to main content

Django Stagers

This package provides a class Stager to stage model instances for bulk creation, update, or deletion at a later time. That way, you can focus on writing sync logic without worrying about keeping track of model instances or their unique identifiers.

Installation

Install using pip:

pip install django-stagers

Import the Stager class:

from django_stagers import Stager

Usage

Instantiate a Stager class (optionally with a type for better type-hinting) and then call the create() function to add models. When any of the three staging methods create(), delete() or update() are called, though, the corresponding action is not actually taken in the database until the user calls commit(), at which point all of the staged actions are run in bulk fashion.

from django_stagers import Stager

foo_stager = Stager[Foo](queryset=Foo.objects.all(), key="id")

foo_stager.create(Foo(attr="abc"))
foo_stager.create(Foo(attr="def"))
...

foo_stager.commit()

The output of the operation will look something like this:

Sat Nov 2 2024 2:36:37 PM [INFO    ]: Committing staged Foo instances.
Sat Nov 2 2024 2:36:37 PM [INFO    ]: Created     37 Foo instances.

Access Existing Instances

Another key feature of stagers is that they keep track of existing model instances in the database using the existing attribute. This way, it is easy to check whether a new object is already tracked in the django database or has already been staged previously.

for serialized_foo in serialized_foos:
  if existing_foo := foo_stager.existing.get(serialized_foo['key']):
    foo_stager.update(serialized_foo['key'], 'attr', serialized_foo['attr'])
  else:
    foo_stager.create(Foo(**serialized_foo))
...

foo_stager.commit()

Metadata

Release files for django-stagers 0.1.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-stagers 0.1.0
File Size Uploaded Provenance Actions
django_stagers-0.1.0.tar.gz 7.8 kB Without provenance Details for django_stagers-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-stagers 0.1.0
File Interpreter ABI Platform Actions
django_stagers-0.1.0-py3-none-any.whl Python 3 none any Details for django_stagers-0.1.0-py3-none-any.whl

Total release size: 15.0 kB

Release files / django_stagers-0.1.0.tar.gz

Download URL django_stagers-0.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b37ad3755fcdb92386737953c520dadba5865b9ee341681e727455901ed29f6b
BLAKE2b-256 checksum
How to use checksums
7246b1a05b36f97e29f1c2a3721e54766a97a05c79284d59801a8c5efff93312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / django_stagers-0.1.0-py3-none-any.whl

Download URL django_stagers-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
378a2ba89a1b9caf44cb60ecb7a5831a587fc46d7afb868d485afce145eee76a
BLAKE2b-256 checksum
How to use checksums
6104e9906206805540f841298e1cf29e105a46cbf6452ef6d24fdbbac8230d85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for django-stagers 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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