Is there a way to apply FK options (db_constraint, on_delete, etc.) to the "_ptr" column automatically created when using multi-table inheritence? I want to stop Django from emulating on delete cascade behavior and have the database perform that natively.
Asked
Active
Viewed 913 times
1 Answers
2
I found a way to do this:
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

partizan
- 319
- 3
- 7