{{{
The following content types are stale and need to be deleted:
auth | group_permissions
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: yes
}}}
At this point, the user has no way to tell whether they should answer
'yes' or 'no'.
Usually they will type 'no' until they get bored, say a quick prayer and
type 'yes'.
----
Django contains infrastructure to determine how many objects will be
deleted.
{{{
>>> ct = ContentType.objects.get(app_label='auth',
model='group_permissions')
>>> collector = NestedObjects(using=DEFAULT_DB_ALIAS)
>>> collector.collect([ct])
>>> print(collector.nested())
[<ContentType: group-permission relationship>]
}}}
It would be helpful to display the list of objects that will be deleted or
at least the number of objects.
If the collector returns just the original object, perhaps migrate could
even proceed with the deletion without asking.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
Yes, this would be great. I ran into this just yesterday, and indeed
answered no because I just wasn't sure enough. I'm not sure whether
automatic deletion if there are no other objects is good - somehow it
seems to me that migrate should not automatically delete such data even if
it seems harmless.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:1>
Comment (by aaugustin):
The argument for deleting automatically is that content types are created
automatically.
They're mostly a technicality of the admin's history log, not a user-
visible feature.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:2>
Comment (by carljm):
I _wish_ content types were an implementation detail (or didn't exist at
all), but unfortunately I don't think that's the case. They are a core
part of the GenericForeignKey, which is very much a user-visible feature.
And the ContentType model itself is documented as a user-visible feature,
as well, so it would be entirely reasonable for people to have cascading
FKs pointing to ContentType, and that would be within public documented
API.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:3>
Comment (by aaugustin):
s/feature/footgun/ ;-)
In case I wasn't clear enough, I consider automatic deletion acceptable
only when there are no related objects that the cascade would delete, not
even admin log entries.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:4>
* status: new => closed
* resolution: => duplicate
Comment:
Dup of #18682.
--
Ticket URL: <https://code.djangoproject.com/ticket/24546#comment:5>