开发者

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜