V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · 3170 views
    This topic created in 4045 days ago, the information mentioned may be changed or developed.
    比如说现在想增加一个评论,评论是存在另外一个表里,在展示Product的详情页的时候,想把这个商品的评论都展示出来,我想最好的办法就是给Product增加方法,或者是扩展action?
    2 replies    2015-04-11 18:48:41 +08:00
    wph95
        2
    wph95  
       Apr 11, 2015
    评论(comment)模型(model)加个ForeignKey 连到Product
    comment = models.ForeignKey("Product")


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