Django admin: changing two unique values ​​at the same time

I have a model containing IntegerField 'order' and I want to change this attribute on the admin page. The 'order' attribute is basic. I added this field to list_editable in MyModelAdmin . It works correctly when I change only one instance, but when I want to swap two rows at the same time, this will not work.

For instance:

 Model1-Order:5 , Model2-Order: 6 

and on the admin page I change orders to

 Model1-Order:6 , Model2-Order: 5 

an exception occurs.

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

+4
source share

Source: https://habr.com/ru/post/1499116/


All Articles