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
sevenQu
V2EX  ›  Python

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

  •  
  •   sevenQu · 2018-03-24 19:28:32 +08:00 · 2433 次点击
    这是一个创建于 2197 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    2 条回复    2018-03-24 20:36:10 +08:00
    sevenQu
        2
    sevenQu  
    OP
       2018-03-24 20:36:10 +08:00
    @mrzys 感谢,我解决了,之前试过,看完更清楚了,发现 order_by 里的参数比较坑,没什么提示,我试了几次,可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2859 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:43 · PVG 19:43 · LAX 04:43 · JFK 07:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.