Answer the question
In order to leave comments, you need to log in
How to move Posts up and down in Django?
There was a problem with the implementation of the ability to move posts - higher, lower. Django project. From everything that I googled, there are implementations on Vue, React, etc. But it is the implementation of such a movement on Django that is of interest, even if it is with reloading the entire page - but without much intervention of additional libraries.
Maybe someone did, tell me or give me an idea. All helpful answers will be marked as correct.
PS: According to the implementation, I myself guess that you need an additional field in the Order type Model and assign an index to it and change it when sorting. But how to actually implement this, from which side to approach, was a little lost.
Answer the question
In order to leave comments, you need to log in
As simple as possible:
in the Post model, add the field Integer ordering = models.IntegetField(default=0)
in the Meta of the model, add: ordering = ['ordering']
In the Admin panel, put down the necessary order in the ordering fields.
...
Profit.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question