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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e88cd3f954d44feef6c06d44267a17f289cc65f42eb802b44091ec7e50e5f36c |
|
MD5 | 92d4f6ad8a4f903aea6423006d465889 |
|
BLAKE2b-256 | 9a94b943a991c8348fc7a9d0f7894a8cab7087a477d4651a7e02c7dd099b1fa9 |
Hashes for django_super_deduper-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7e0b971e917ef4ac28a1f40e5bf3c0eb66f4d09ca04c079654333e6da0e3008 |
|
MD5 | 972d0b2794a5289217bfc6d5a53cf363 |
|
BLAKE2b-256 | c82a9a10418648cb439acc6c9677579e7753ff5f70cb9cb831dfa5c56f42c643 |