Utilities for deduping Django model instances
Project description
A collection of classes and utilities to aid in de-duping Django model instances.
Install
pip install django-super-deduper
Usage
Merging Duplicate Instances
By default any empty values on the primary object will take the value from the duplicates. Additionally, any related one-to-one, one-to-many, and many-to-many related objects will be updated to reference the primary object.
> from django_super_deduper.merge import MergedModelInstance > primary_object = Model.objects.create(attr_A=None, attr_B='') > alias_object_1 = Model.objects.create(attr_A=X) > alias_object_2 = Model.objects.create(attr_B=Y) > merged_object = MergedModelInstance.create(primary_object, [alias_object_1, alias_object_2]) > merged_object.attr_A X > merged_object.attr_B Y
Improvements
Support multiple merging strategies
Logging
This package does have some rudimentary logging for debugging purposes. Add this snippet to your Django logging settings to enable it:
LOGGING = { 'loggers': { 'django_super_deduper': { 'handlers': ['console'], 'level': 'DEBUG', }, }
References
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
Close
Hashes for django-super-deduper-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324ab4658faaef3d8adca0f00f951a3da062505970415d6148c53cb9981cb548 |
|
MD5 | 407b69400a12aec4f36ae832a4027dc9 |
|
BLAKE2b-256 | 124340835a8aec0d627f8dc9094a0e7b328f3edb950388aa5f4940b4f70b57e9 |