# django-bulk-save: efficient bulk persistence with custom pre-save hooks

**URL:** <https://forum.djangoproject.com/t/django-bulk-save-efficient-bulk-persistence-with-custom-pre-save-hooks/46174>\
**Category:** Packages\
**Created:** [October 11, 2026, 8:50pm UTC](https://forum.djangoproject.com/t/django-bulk-save-efficient-bulk-persistence-with-custom-pre-save-hooks/46174 "2026-10-11T20:50:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorst97](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lorst97/32/33495_2.png) [@lorst97](https://forum.djangoproject.com/u/lorst97)\
**Post date:** [October 11, 2026, 8:50pm UTC](https://forum.djangoproject.com/t/django-bulk-save-efficient-bulk-persistence-with-custom-pre-save-hooks/46174/1 "2026-10-11T20:50:52Z")

</div>

Hi everyone!

I’m currently developing **django-bulk-save** , a Python package born from a performance issue I encountered while working on a large Django codebase.

The goal is to make bulk persistence easier when Django models require custom pre-save logic.

In Django, `bulk_update()` and `bulk_create()` are great for reducing database queries, but they bypass custom `save()` implementations. This can become problematic when models rely on additional logic before being persisted.

In my case, I ended up calling `.save()` inside a `for` loop in several situations, resulting in individual database operations that I wanted to avoid.

**django-bulk-save** aims to address this by introducing a `BulkSaveableModel` that provides:

- A customizable `before_save()` hook for model-specific logic.
- A context manager for registering instances and managing the bulk persistence lifecycle.
- Automatic handling of bulk creates and updates within a database transaction.
- PostgreSQL-optimized bulk operations powered by **pgbulk**.

The idea is to keep the API simple while allowing developers to perform bulk operations without sacrificing custom pre-save logic.

The package is still in its early stages.

**GitHub:** [https://github.com/lorst97/django-bulk-save](https://github.com/lorst97/django-bulk-save?utm_source=chatgpt.com)

Contributions and suggestions are very welcome!
