What is the best way to merge records?

I wish to be able to merge records and am seeking the best way to do it.

The model in question is called Horses. And each horse have attributes (name, colour sex etc) and is a foreign key to things like performance (eg races they’ve won) and photos.

Obviously there is the manual way, or the Django dedupe plugin.

Is there another way to merge records where I can define the master record, that also covers foreign keys and many to many relationships?

I fear I need to code a manual solution but would be interested in you learned people’s schooling me if there is a better way.

Thank you.

Can you be more specific about what the issue is you’re trying to resolve? I’m guessing you have some duplicate Horses, but they’re linked by ForeignKey relationships to different Performance and Photo models.

If I’m understanding you correctly, I’m not aware of any automated tool that would do this - but having done multiple projects like this, it’s really not all that difficult.

1 Like

Yes you have it correct.

There are multiple entries by different users for the same horse. So I need to merge the horse entries into one

I suspect I just need to do it manually.

Whether manually or scripted probably depends upon how many duplicates you have. If it’s < 10, yea, I’d probably just use the django shell to get it straightened out.

You might also want to add something to your model to help prevent this from happening in the future.

1 Like