Skip to main content

Bulk update for django.

Project description

django-bulk-update
==================================

Simple bulk update over Django ORM or with helper function.

This project aims to bulk update given objects using **one query** over **Django ORM**.

Usage
==================================
With manager:

from bulk_update.manager import BulkUpdateManager

class PersonManager(BulkUpdateManager):
pass

class Person(models.Model):
...
objects = PersonManager()

random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]

Person.objects.bulk_update(people, update_fields=['name']) # updates only name column
Person.objects.bulk_update(people, exclude_fields=['username']) # updates all columns except username
Person.objects.bulk_update(people) # updates all columns


With helper:

from bulk_update.helper import bulk_update

random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]

bulk_update(people, update_fields=['name']) # updates only name column
bulk_update(people, exclude_fields=['username']) # updates all columns except username
bulk_update(people, using='someotherdb') # updates all columns using the given db
bulk_update(people) # updates all columns using the default db

Installation
==================================


Requirements
==================================
Django 1.2+

TODO
==================================
- Add batch_size option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-bulk-update-0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django-bulk-update-0.1.macosx-10.9-intel.exe (66.9 kB view details)

Uploaded Source

File details

Details for the file django-bulk-update-0.1.tar.gz.

File metadata

File hashes

Hashes for django-bulk-update-0.1.tar.gz
Algorithm Hash digest
SHA256 3a70ebbdb39b4c09acaa8074971415d10d43631035a244886c76a9d9c6630fbc
MD5 7cddec8458d4309aee82bda7b49bfe54
BLAKE2b-256 368c4534a3b36a0c80850aa148d694a417a3c24cf1409b2e5824e05cb712fdcc

See more details on using hashes here.

File details

Details for the file django-bulk-update-0.1.macosx-10.9-intel.exe.

File metadata

File hashes

Hashes for django-bulk-update-0.1.macosx-10.9-intel.exe
Algorithm Hash digest
SHA256 f06f58e27743d3ae2a4d79563108b3c8681b6a422ba673d7053fa0abec9a5ce3
MD5 95f0008c8223931dbfa1956f39d0fa58
BLAKE2b-256 d5b311b57c0c3a6e35c84ef60a2519dd2cae6742022bc46e2057cc50762bcb33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page