[Answer]-Django GenericRelation not working

1👍

As you mentioned it, the documentation is clear about what happens when you delete an object that has a Generic Relation field (Django deletes all objects that have a foreign key to the object with GenericRelation).

So this is basically Django’s fault (probably some problem with the abstract classes), BUT there is a way to overcome this situation.

By using pre_delete you can delete all objects that have a foreign key to the object with GenericRelation.

Some examples of pre_delete signal can be found here: http://www.koopman.me/2015/01/django-signals-example/

👤Behzad

Leave a comment