Utilities for deduping Django model instances
Project description
A collection of classes and utilities to aid in de-duping Django model instances.
Requirements
Python 3.6
Django 1.11
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
Recursive merging of related one-to-one objects
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
Built Distribution
Hashes for django-super-deduper-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 184cf501211d81b2de32d0556ff896a804a15d34af799eb40c796423637e61d7 |
|
MD5 | b809aa0a317a38fb6d96beaebb327ac8 |
|
BLAKE2b-256 | 33e705a6d219e0d687659c59f0ee27d59241fe030b891fb456db17e3c60c1fcf |
Hashes for django_super_deduper-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 017f6b1efb0d85dcbff58b3b73a6a42833956f8985a249c5857d3db785d409b4 |
|
MD5 | b9a086503ade85f85bd3b791ed4a800b |
|
BLAKE2b-256 | 947a39198c045e41388e2d2ba006de9155843fee27bc84fb24785d48b22086e4 |