Annons
python manage.py remove_stale_contenttypes --noinput
By following this guide, you'll have a better understanding of the concept of stale content types in Django, their implications, and how to effectively remove them. Happy coding!
When you run this, Django will present you with a list of stale content types it found and ask for confirmation before deleting them.
def handle(self, *args, **options): ContentType.objects.filter(stale=True).delete()
Here’s a concise, structured review of Django’s remove_stale_contenttypes management command.
python manage.py remove_stale_contenttypes
Every time you create a new model, Django adds a record to the django_content_type table. This table powers features like generic foreign keys and generic relations.
Annons