Make django.db.models.deletion.Collector public?

134 views
Skip to first unread message

Shai Berger

unread,
Jul 18, 2016, 9:00:59 AM7/18/16
to django-d...@googlegroups.com
Hi,

We're implementing a feature where we need to access all the dependent objects
for a given set of objects -- much like the Admin's deletion does. I note that
we are not the first with this need, and I bring the SO question[1] as
evidence. As you can see in that question, it turns out that already in
Django, there is more than one such collector -- the one[2] used in delete()
is not exactly suitable for use in the Admin[3].

Shouldn't we make the collector class -- or, at least, some API to achieve the
same goal -- public?

Shai

[1]http://stackoverflow.com/questions/12158714/
[2]https://github.com/django/django/blob/c339a5a6/django/db/models/deletion.py#L64
[3]https://github.com/django/django/blob/f6681393/django/contrib/admin/utils.py#L176

Romain Garrigues

unread,
Jul 21, 2016, 3:32:00 AM7/21/16
to Django developers (Contributions to Django itself)
Hi Shai,

I needed a similar feature in one of my projects.
I have started to use and try to extend the Django collector used in Admin deletion, and finished with something I was not really happy about...
I have then created a full collector (following all relations, foreign keys, manytomany, GFK, ...) named DeepCollector and that I released as django-deep-collector[1] package.
Some parameters allow you to collect some models, excludes other ones, ...
I actively maintain and use it on a daily basis in a big project (300+ tables) to download some production data and load it in my local environment.

I hope this can help!

Romain.

Reply all
Reply to author
Forward
0 new messages