How can I order elements in this case? - Django
So I have a list of models, don't think the structure of these models is important. In this case Articles.
开发者_JAVA百科So these Articles are ordered by popularity between a rank of 1 to 100, all the other articles have no ranks.
Whenever I update the rank of a model the model with equivalent rank must loose its rank.
Any ideas?
Do you mean something like this?
def update_rank(rank, article):
old = Article.object.get(rank=rank)
old.rank = None
old.save()
article.rank = rank
article.save()
精彩评论