/django-bulk-saving

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

Django Bulk Saving

Test package Coverage Status

About

This package provides utility for saving multiple Django model instances using one SQL query.

Install

pip install django-bulk-saving

Usage

Inherit from BulkSavableModel:

from bulk_saving.models import BulkSavableModel
from django.db import models


class Product(BulkSavableModel):
    name = models.CharField(max_length=30)

Use as follows:

with Product.bulk_saving():
    for idx, product in enumerate(Product.objects.all(), 1):
        product.name = 'Product nr %s' % idx
        product.save_later()

Products will be saved after exit from context.

License

The Django Wicked Historian package is licensed under the FreeBSD License.