Skip to main content

django-object-utils

This small library provides helpers for updating Django model objects without race conditions.

Installation

pip install django-object-utils

Usage

from django_object_utils import reload_object, update_object, lock_object

user = User.objects.get(pk=1)

# Reload object in-place with the latest version from the database
reload_object(user)

# Run SQL UPDATE for certain fields only and update the Python object
update_object(user, username='john', email='john@gmail.com')

# Run SQL UPDATE and then reload the object from the database
update_object(user, balance=F('balance')+payment, reload=True)

if request.method == 'POST':
        with transaction.atomic():
                # Enter a critical section and ensure that the object is the latest version.
                # Use the corresponding database row as the synchronization monitor.
                lock_object(user)
                form = UserForm(data=request.POST)
                form.save()

Metadata

Release files for django-object-utils 0.0.1

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-object-utils 0.0.1
File Size Uploaded Provenance Actions
django-object-utils-0.0.1.tar.gz 1.8 kB Without provenance Details for django-object-utils-0.0.1.tar.gz

Release files / django-object-utils-0.0.1.tar.gz

Download URL django-object-utils-0.0.1.tar.gz
Size 1.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3fdc672bbec1df7cbc03cf097887ae66886aac946c392b5a0772b21321402b9e
BLAKE2b-256 checksum
How to use checksums
b1b8f7223010a4fea7f72daee2c34d9871346b39ba087b5d9f6bd2498a3fdb6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-object-utils 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

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