推荐学习书目
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
sevenQu
V2EX  ›  Python

flask-sqlalchemy, product 一对多 img,使用 product.img.all()可以获取到 product 对应的全部图片, img 里有一个 order 作为图片顺序的标识,如何将 img 进一步进行降序或升序

  •  
  •   sevenQu · Mar 24, 2018 · 3282 views
    This topic created in 3000 days ago, the information mentioned may be changed or developed.

    product 是一张表
    img 是一张表
    定义好关联,product 一对多 img
    product.img.all(),可以获取到 product 对应的 img
    img 里有一个 order 作为图片顺序的标识,如何将 img 进一步进行降序或升序

    2 replies    2018-03-24 20:36:10 +08:00
    sevenQu
        2
    sevenQu  
    OP
       Mar 24, 2018
    @mrzys 感谢,我解决了,之前试过,看完更清楚了,发现 order_by 里的参数比较坑,没什么提示,我试了几次,可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5706 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 03:28 · PVG 11:28 · LAX 20:28 · JFK 23:28
    ♥ Do have faith in what you're doing.