from django.contrib.admin.models import LogEntry
from django.core.management.base import BaseCommand

from nodeconductor.cost_tracking import models as cost_tracking_models


class Command(BaseCommand):
    help = "Remove instances that have FK to stale content types."

    def handle(self, *args, **options):
        for estimate in cost_tracking_models.PriceEstimate.objects.all():
            print estimate.app
            if estimate.content_type.model_class() is None:
                estimate.delete()

        for entry in LogEntry.objects.all():
            if entry.content_type.model_class() is None:
                entry.delete()

Add command that deletes stale content types
Add command that deletes stale content types

 - nc-1511
