Django admin: Change two unique values in same time
Asked Answered
E

0

6

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.

Equilateral answered 27/8, 2013 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.