Answer the question
In order to leave comments, you need to log in
Alternative sorting on Django?
Hello.
Need help.
Briefly about the project. A typical django news site where each news item is sorted by release date.
It is necessary to implement the possibility of alternative sorting, not by date, but with the ability to raise one news item higher than another, or lower it by one item lower.
On the main page, not in the admin panel.
From my ideas and thoughts: in the Model, add the field ordering = models.PositiveIntegerField() , and so that when adding each news, the index (ordering) is hidden in this field , type in order, by the function - "Total number of indexes" + 1. And then, when you click on the down arrow (on the news itself)the news moves lower, swapping the indexes with the underlying news.
Here is an idea for such sorting.
Does anyone have any better ideas?? Or maybe someone has already encountered and made a similar implementation to change the order of displaying the News ??
Any advice, any help is welcome. Don't be indifferent.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question