python - Django 在不是用 generic relation 的情况下,如何做到通用性?
PHP中文网
PHP中文网 2017-04-17 17:51:02
0
2
328

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

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
洪涛

You can use ManyToManyField on the model to point to Comment

巴扎黑

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!