django-bulk-update-or-create
django-bulk-update-or-create copied to clipboard
`bulk_update_or_create` for Django model managers
As `update_fields` is passed to `bulk_update` but ignored when falling back to `.create`, all the values from the object are used when creating. This is actually documented in `update_fields` docs:...
Get exception FieldDoesNotExist when match_field is not specified. [match_field='pk'](https://github.com/fopina/django-bulk-update-or-create/blob/a1f20ff146b3e5fd9612e77f799d9233488fe71a/bulk_update_or_create/query.py#L114) [match_field = (match_field,) if isinstance(match_field, str) else match_field](https://github.com/fopina/django-bulk-update-or-create/blob/a1f20ff146b3e5fd9612e77f799d9233488fe71a/bulk_update_or_create/query.py#L124) [_match_fields = [self.model._meta.get_field(name) for name in match_field]](https://github.com/fopina/django-bulk-update-or-create/blob/a1f20ff146b3e5fd9612e77f799d9233488fe71a/bulk_update_or_create/query.py#L125) Easy way to reproduce from django.contrib.auth...
I do this: ``` MyModel.objects.bulk_update_or_create(objs, ['name', 'slug', 'rank', 'symbol', 'is_active'], match_field='id') ``` and I get this error: ``` duplicate key value violates unique constraint "mymodel_pkey" DETAIL: Key (id)=(1) already exists....
Can't receive post_save signal when bulk update instance
Added type hinting for each class method in query.py.
I am currently using django-bulk-update-or-create and I would like to know if this project has been tested already in concurrent environments. Since the selection of objects to be updated is...
Hi, Does this support all the databases that django supports ? It would be good to make a note in the README, I'm interested in Postgres and Sqlite. Cheers Stuart
Title when calling the function to update all the fields instead of calling ``` model_field_names = [field.name for field in model._meta.get_fields()] model.objects.bulk_update_or_create(bulk_data, model_field_names, match_field='object_guid') ``` we call `model.objects.bulk_update_or_create(bulk_data, 'all', match_field='object_guid')`
As a select is done before bulk_update, a check to see if object is actually being changed could be done (in a soft way, as type converters might make it...