S
S
Sergey Nizhny Novgorod2017-03-04 15:09:01
Django
Sergey Nizhny Novgorod, 2017-03-04 15:09:01

How to switch id on offsets in output list in Django?

Hello everyone
We have a student model. There are 100 students in total. Output to the page is carried out by ID (1, 2, 3, and so on). We need to move a few posts up. Those. actually change their ID and the entire list below.
Logic suggests that you need to:
1) Take the entry itself to increase its ID
2) Take the break point and loop +1 for the ID for the remaining entries.
But, in Django ID is a unique field and you cannot set it to another number if it already exists.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2017-03-04
@Terras

Add a field in which the position of the student will be
Sort by it

D
devalone, 2017-03-04
@devalone

So create another field, sort by it and change as you want

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question