Skip to main content

save_deep

This package first saves all the children of the given oject and then the object itself. It solves the error: ValueError: save() prohibited to prevent data loss due to unsaved related object '<<foreign_object>>'.

Note: it does not work (yet) with circular dependencies

Example

Say you have this this model

class Company(models.Model):
    name = models.CharField(max_length=256)

class Employee(models.Model):
    username = models.CharField(max_length=256)
    company = models.ForeignKey(Company, on_delete=models.CASCADE)

If you try to do

Employee(username='tom', company=Company(name='some-name')).save()

you get

ValueError: save() prohibited to prevent data loss due to unsaved related object '<<foreign_object>>'.

But if you use save_deep, the company is saved first, then the employee

employee = save_deep(Employee(username='tom', company=Company(name='some-name')))

This works with a deeply nested object-tree and with updates (and update/create-mixes) as well as long as there are no circular dependencies.

Metadata

Release files for django-save-deep 0.0.2

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-save-deep 0.0.2
File Size Uploaded
django_save_deep-0.0.2.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-save-deep 0.0.2
File Interpreter ABI Platform
django_save_deep-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / django_save_deep-0.0.2.tar.gz

Download URL django_save_deep-0.0.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e3e2d6ff3b5987ec30b6cb19c35c4c0a88c85157a63613d7c2d514e183814303
BLAKE2b-256 checksum
How to use checksums
88be558c343602b4f2d71ceac8fa4af6f1a3f9f5447d17db7a833eaf105500ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release files / django_save_deep-0.0.2-py3-none-any.whl

Download URL django_save_deep-0.0.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7438604c09364ab3b5dd79b672544ae21da56b3b706031cbbc71e4135762ac0
BLAKE2b-256 checksum
How to use checksums
ffd56d7266d1475efc8185bd6ac787c0ac300de75c16440c04224429692e3816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

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