A collection of classes and utilities to aid in de-duping Django model instances.
- Python 3.6
- Django 1.11
pip install django-super-deduper
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
- Support multiple merging strategies
- Recursive merging of related one-to-one objects
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',
},
},
}
- https://djangosnippets.org/snippets/2283/
- https://stackoverflow.com/questions/3393378/django-merging-objects
Pre-reqs:
pip install pypandoc twine
brew install pandoc
- Draft a new release and create new tag in Github
- Run
python3 setup.py sdist bdist_wheel
onmaster
- Upload to pypi
python -m twine upload dist/*