tanteng
V2EX  ›  Django

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

  •  
  •   tanteng ·
    tanteng · May 15, 2015 · 4580 views
    This topic created in 4097 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   ·   870 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 21:12 · PVG 05:12 · LAX 14:12 · JFK 17:12
    ♥ Do have faith in what you're doing.