@@ -0,0 +1,1190 @@
+from django.core.management.base import BaseCommand%0Afrom django.db.models import Count%0Afrom django.utils.text import slugify%0A%0Afrom scuole.campuses.models import Campus%0A%0Aclass Command(BaseCommand):%0A    help = %22Dedupe Campus slugs by adding the county name to the end.%22%0A%0A    def handle(self, *args, **options):%0A        duplicate_slugs = (%0A            Campus.objects.values(%22slug%22)%0A            .annotate(total=Count(%22slug%22))%0A            .filter(total__gt=1)%0A        )%0A%0A        print('DUPLICATE SLUGS', duplicate_slugs)%0A%0A        # loop through all duplicate slugs%0A        for duplicate in duplicate_slugs:%0A            slug = duplicate%5B'slug'%5D%0A%0A            # for campus in Campus.objects.filter(slug=slug):%0A            #     if campus.city != None:%0A            #       city_slug = slugify(campus.city, allow_unicode=True)%0A            #       campus.slug = f%22%7Bcampus.slug%7D-%7Bcity_slug%7D%22%0A            #       campus.save()%0A%0A                # city_slug = slugify(campus.city, allow_unicode=True)%0A                # campus.slug = f%22%7Bcampus.slug%7D-%7Bcity_slug%7D%22%0A                # print(slugify(campus.city, allow_unicode=True))%0A                # print('SLUG', campus.slug)%0A                # campus.save()%0A

Add `dedupecampusslugs` file to dedupe campus slugs for campuses that have the same name and same district