V
V
vixh2011-04-27 22:50:08
Django
vixh, 2011-04-27 22:50:08

Deleting an inherited model in Django?

We have two models:
class A(models.Model): pass # Non-abstract
class B(A): pass
Deleting an object A, you need to delete a derived B. The opposite option is not suitable.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Riateche, 2011-04-28
@Riateche

If I understand correctly, it doesn't matter here that B inherits from A. You just have a corresponding object of class B for every object of class A, right? Then signals.pre_delete will help you

B
black_bunny, 2011-04-28
@black_bunny

If I understand correctly, what you need is OneToOneField :

class B(A):
  a = models.OneToOneField(A, parent_link=True)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question