Home  >  Q&A  >  body text

python - Django 在不是用 generic relation 的情况下,如何做到通用性?

比如我想做一个评论 app ,假如我不使用 generic relation,如何做到这个评论 app 可以用于任何 Model?

PHP中文网PHP中文网2741 days ago342

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:53:02

    You can use ManyToManyField on the model to point to Comment

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:53:02

    Why not use GenericForeignKey? It’s a very useful thing.

    reply
    0
  • Cancelreply