saxix/django-adminactions

Option to always select lower id as Master

int-ua opened this issue · 4 comments

Can it be done? Because it seems that since lower ids were always created before higher ones it greatly increases chances of latter ones being duplicates with lower number of relations.

saxix commented

could be an option, I'm thinking to add a "swap" option on the preview screen that replay the preview with the inverted records, this should be a better improvement. Thanks for the hint, I'll try to work on it soon, but not free time available at the moment.

But swap is already available on the first screen, so manual selection of master is possible anyway, what I suggest is adding a global option [1] to select id in a standardised way on different models.

[1] Do I understand correctly that currently it respects Models' ordering because just queryset.all() is executed in

master, other = queryset.all()
? And I can imagine there is cases where it's desired.

Something like ADMINACTIONS_MERGE_MASTER_SELECTION with options

  • default: default ordering defined on Model
  • lower_id: order by 'id'
  • higher_id: order by '-id'

What do you think?

saxix commented

ops... seems I have forgotten my code..I got your point and I found your idea reasonable.
Feel free to post a PR and relative documentation. I'll happy to merge it.