Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法将 FK 选项(db_constraint、on_delete 等)应用于使用多表继承时自动创建的“_ptr”列?我想阻止 Django 模拟删除级联行为并让数据库本地执行该行为。
我找到了一种方法来做到这一点:
class Article(models.Model): name = models.CharField() class PersonalArticle(Article): user = models.ForeignKey('auth.User') PersonalArticle._meta.get_field('article_ptr').rel.on_delete = models.DO_NOTHING