Django admin: Change two unique values in same time

327 Views Asked by At

I have a model that contains an IntegerField 'order' and I want to change this attribute in admin page. The 'order' attribute is primary. I added this field to list_editable in MyModelAdmin. It works properly when I change only one instance but when I want to swap two rows in same time, it doesn't work.

For example:

Model1-Order:5 , Model2-Order: 6

and in admin page, I change the orders to

Model1-Order:6 , Model2-Order: 5

it raises an exception.

I searched and found 'formset' but I don't know how to use it in ModelAdmin.

0

There are 0 best solutions below