推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
python30
V2EX  ›  Python

django 文章内容页分页显示 这个怎么做? 不是列表分页。是单篇文章内容分页,有什么思路吗?

  •  
  •   python30 · Oct 30, 2018 · 2008 views
    This topic created in 2907 days ago, the information mentioned may be changed or developed.
    django 文章内容页分页显示 这个怎么做? 不是列表分页。是单篇文章内容分页,有什么思路吗?



    类似这样的

    谢谢~
    3 replies  •  2018-10-30 16:44:36 +08:00
    neoblackcap
        1
    neoblackcap  
       Oct 30, 2018
    理论上还是将你的文章内容转化成列表(根据长度,或者特定分割符等等),然后调用 django 自带 paginator 就可以了
    fancyhan
        2
    fancyhan  
       Oct 30, 2018
    比如一页显示五百字,你读了内容,发现 1200 字。处以 500=2 余 200 字,分三页,第一次只返回前 500 字,不是很简单嘛
    owenliang
        3
    owenliang  
       Oct 30, 2018
    这个显然前端做效果啊,不用走后端啊,就和点击展开一个意思。

    前端拿到富文本以后,看一下一共多少个直接 children node,然后切成几份放数组里,点一次翻页放出来一波。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5950 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 02:45 · PVG 10:45 · LAX 19:45 · JFK 22:45
    ♥ Do have faith in what you're doing.