Changes between Initial Version and Version 2 of Ticket #31123
- Timestamp:
- Jan 29, 2020, 10:31:02 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31123
- Property Summary remove_stale_contenttypes doesn't remove entries for stale apps → Add option to remove_stale_contenttypes to remove entries for nonexistent apps.
- Property Has patch unset
- Property Triage Stage Unreviewed → Accepted
- Property Type Bug → New feature
- Property Version 3.0 → master
-
Ticket #31123 – Description
initial v2 1 remove_stale_contenttypes only removes stale content types for stale models in installed apps. It doesn't remove stale content types whose app was either removed or renamed.1 Add an option (disabled by default) to `remove_stale_contenttypes` command to remove entries also for nonexistent apps. 2 2 3 Test: 4 Comment out the line that limits the available apps. 5 # Speed up tests by avoiding retrieving ContentTypes for all test apps. 6 # available_apps = ['contenttypes_tests', 'no_models', 'django.contrib.contenttypes'] 7 8 def test_contenttypes_removed_for_apps_not_in_installed_apps(self): 9 ContentType.objects.create(app_label='stale_app', model='Fake') 10 with mock.patch('builtins.input', return_value='yes'), captured_stdout() as stdout: 11 call_command('remove_stale_contenttypes', verbosity=2) 12 self.assertIn("Deleting stale content type 'stale_app | Fake'", stdout.getvalue()) 13 self.assertEqual(ContentType.objects.count(), self.before_count) 3 Based on [https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/django-developers/0WrbU_Kc2Z0 discussion].