I’m sorry not to be clear I’ll try to explain in other words.
I have games and each Game
contain multiple puzzles (Task
). Those tasks must be placed in a given order so the player is passing all tasks of a game in the established order.
I configure the game and the tasks in the admin interface. The order is as they are created for each game so let say I have Game1 with the following tasks in order [Taks1, Task3, Taks8]
After testing a game I decided to add a new Task (example Task10) and creting a new Taks for that Game, the order will be consecutive [Taks1, Task3, Taks8, Task10] but I would like to reorder for example like this: [Taks1, Task10, Task3, Taks8]
Even in terms of database design relationship haven’t intrinsic order, django provide a way to do that using class Meta option order_with_respect_to in your model:
Makes this object orderable with respect to the given field, usually a ForeignKey
. This can be used to make related objects orderable with respect to a parent object.
And regarding that methods, djanjo automatically defines them:
When order_with_respect_to
is set, two additional methods are provided to retrieve and to set the order of the related objects: get_RELATED_order()
and set_RELATED_order()
, where RELATED
is the lowercased model name.
I would like to be able to modify that order in the admin interface. Django provides methods to reorder the relationship but there is no information about how to implement that in the admin interface like any other field to show or edit. It would be great a specific widget to reorder a list. So I don’t know how to implement the possibility to reorder that in django admin interface.
Please, let me know if still is not clear. English is not my mother tongue and sometimes it’s a little bit hard to me express complex explanations.