Opened 8 years ago

Closed 7 years ago

#26936 closed Bug (fixed)

Stale content type deletion stops working if all models in an app are deleted

Reported by: Baptiste Mispelon Owned by: Pavel
Component: contrib.contenttypes Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduce:

1) Create an app with one model in its models.py
2) Add it to settings.INSTALLED_APPS, run makemakigrations, and migrate
3) Delete the model from models.py, run makemigrations, then migrate

At step 3), Django deletes the model from the database (as expected) but doesn't prompt the user to delete the now stale content type (as normally happens when you run migrate).

I believe this is called by the if not app_config.models_module: return statement in update_contenttypes() [1]

[1] https://github.com/django/django/blob/master/django/contrib/contenttypes/management.py#L95-L96

Change History (8)

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Pavel, 8 years ago

Owner: changed from nobody to Pavel
Status: newassigned

Hi,

This issue is reported on version 1.9 but it also reproduces on later versions. Should I make the fix on every release starting with 1.9?

Thanks

comment:4 by Tim Graham, 8 years ago

No, all pull requests should go to master. The committer will determine if it needs to be backported per our supported versions policy. I don't think it would in this case.

comment:5 by Tim Graham, 8 years ago

Has patch: set
Patch needs improvement: set

The PR has some test isolation issues.

comment:6 by Pavel, 8 years ago

Patch needs improvement: unset

Fixed the isolation issues in PR

comment:7 by Pavel, 8 years ago

Updated the pull request according to code review remarks

comment:8 by Tim Graham, 7 years ago

Triage Stage: AcceptedReady for checkin

comment:9 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 874b1f2:

Fixed #26936 -- Fixed stale ContentType deletion in apps without models.

Note: See TracTickets for help on using tickets.
Back to Top