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

[django]cartridge 怎么扩展 Product 这个模型呢

  •  
  •   pythonee · Apr 11, 2015 · 3507 views
    This topic created in 4224 days ago, the information mentioned may be changed or developed.
    比如说现在想增加一个评论,评论是存在另外一个表里,在展示Product的详情页的时候,想把这个商品的评论都展示出来,我想最好的办法就是给Product增加方法,或者是扩展action?
    2 replies  •  2015-04-11 18:48:41 +08:00
    wph95
    wph95
    Apr 11, 2015
    2
    评论(comment)模型(model)加个ForeignKey 连到Product
    comment = models.ForeignKey("Product")


    然后 product.comment_set.all()就是所有的评论queryset
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1318 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 20:05 · PVG 04:05 · LAX 12:05 · JFK 15:05
    ♥ Do have faith in what you're doing.