开发者

How can I order elements in this case? - Django

开发者 https://www.devze.com 2022-12-21 03:04 出处:网络
So I have a list of models, don\'t think the structure of these models is important. In this case Articles.

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

精彩评论

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

关注公众号