V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-10-30 16:14:02 +08:00 · 1286 次点击
    这是一个创建于 2003 天前的主题,其中的信息可能已经有所发展或是发生改变。
    django 文章内容页分页显示 这个怎么做? 不是列表分页。是单篇文章内容分页,有什么思路吗?



    类似这样的

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

    前端拿到富文本以后,看一下一共多少个直接 children node,然后切成几份放数组里,点一次翻页放出来一波。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5255 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 05:42 · PVG 13:42 · LAX 22:42 · JFK 01:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.