3👍
✅
Have you tried this way, first find out those values not null in person2
:
person2_dict = {k: v for k, v in person2.__dict__.iteritems() if v is not None}
Merge them into the target person1
:
person1.__dict__.update(person2_dict)
person1.save()
4👍
Two third party libraries can help deduplicate Django models:
Django Extensions’ merge_model_instances management command.
- [Django]-Getting Django's staticfiles includes working inside Vue.js .vue templates
- [Django]-Django catching any url?
- [Django]-Django and SQL Injection with example
- [Django]-Custom metrics from celery workers into prometheus
Source:stackexchange.com