How to delete all the objects which are referring the current object without DELETE_CASCADE

32 views
Skip to first unread message

mohitdu...@gmail.com

unread,
Jan 3, 2018, 7:03:36 AM1/3/18
to Django users
How to delete all the objects which are referring the current object without DELETE_CASCADE

Jani Tiainen

unread,
Jan 3, 2018, 7:30:04 AM1/3/18
to django...@googlegroups.com
Hi,

As I posted on other thread you can do that using meta api.

But why you want to do that manually. DELETE_CASCADE does the same thing exactly.

3.1.2018 14.03 <mohitdu...@gmail.com> kirjoitti:
How to delete all the objects which are referring the current object without DELETE_CASCADE

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cc50717c-c053-4569-98bc-802b6343f08a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shem Ogumbe

unread,
Jan 4, 2018, 4:15:31 AM1/4/18
to Django users

Question is, why do that when on_delete=models.CASACADE is there to do it for you?

James Schneider

unread,
Jan 4, 2018, 4:23:06 AM1/4/18
to django...@googlegroups.com


On Jan 3, 2018 4:29 AM, "Jani Tiainen" <red...@gmail.com> wrote:
Hi,

As I posted on other thread you can do that using meta api.

But why you want to do that manually. DELETE_CASCADE does the same thing exactly.


While I don't know the motivations of the OP, one reason you may want to do this is for auditing purposes. There may be a requirement to track additions and removals of records. I don't think a cascade delete would capture enough information in such a case, even with a high level of transaction logging.

-James
Reply all
Reply to author
Forward
0 new messages