# coding: utf-8
from django.core.management import BaseCommand
from django.template.defaultfilters import slugify
from unidecode import unidecode

from richard.videos.models import Speaker


class Command(BaseCommand):
    help = 'Fixes speaker slugs'

    def handle(self, *args, **options):

        for speaker in Speaker.objects.all():
            old_slug = speaker.slug
            fixed_slug = slugify(unidecode(speaker.name))
            speaker.save()
            self.stdout.write(u'Changed slug for %s "%s" => %s\n' % (speaker.name, old_slug, fixed_slug))

@@ -381,22 +381,45 @@
         
-fixed_
+try:%0A                speaker.
 slug = s
@@ -454,32 +454,36 @@
 e))%0A            
+    
 speaker.save()%0A 
@@ -481,16 +481,20 @@
 .save()%0A
+    
         
@@ -582,17 +582,131 @@
 ug, 
-fixed_slug)
+speaker.slug))%0A            except Exception:%0A                self.stdout.write(u'Problem fixing slug for %25s%5Cn' %25 speaker.name
 )%0A

Fix management command for fixing slugs