tanteng
V2EX  ›  Django

关于 django objects.all 查询语句的问题

  •  
  •   tanteng ·
    tanteng · May 15, 2015 · 4576 views
    This topic created in 4094 days ago, the information mentioned may be changed or developed.

    经常看到这样的写法:
    article_list = Article.objects.all().order_by('-date')

    这是一次查询出所有的数据吧,根据一般的经验,分页都是先count获取总数,然后用分页函数传参控制每次查询的数据量。Django中这样写是对的吗?新手,求解答。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5771 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 664ms · UTC 02:14 · PVG 10:14 · LAX 19:14 · JFK 22:14
    ♥ Do have faith in what you're doing.