update slug script to ensure unique / ugly hack

This commit is contained in:
Sanj 2012-02-20 19:40:22 +05:30
parent c1aedefbc7
commit 974a57ee1a

View File

@ -4,7 +4,10 @@ from mumbai.models import *
def do():
for cls in [Road, Area, Stop]:
for obj in cls.objects.all():
obj.slug = slugify(obj.display_name)
slug = slugify(obj.display_name)
if cls.objects.filter(slug=slug).count() > 1:
slug += "2"
obj.slug = slug
obj.save()
for r in Route.objects.all():
r.slug = r.alias