From 48580ad4be21ffecf8eeaacee41f0bfedcfdaca2 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 19 Feb 2012 18:37:11 +0530 Subject: [PATCH] add make_slugs script --- chaloBEST/imports/make_slugs.py | 11 +++++++++++ chaloBEST/mumbai/models.py | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 chaloBEST/imports/make_slugs.py diff --git a/chaloBEST/imports/make_slugs.py b/chaloBEST/imports/make_slugs.py new file mode 100644 index 0000000..bad6b41 --- /dev/null +++ b/chaloBEST/imports/make_slugs.py @@ -0,0 +1,11 @@ +from django.template.defaultfilters import slugify +from mumbai.models import * + +def do(): + for cls in [Road, Area, Stop]: + for obj in cls.objects.all(): + obj.slug = slugify(obj.display_name) + obj.save() + for r in Route.objects.all(): + r.slug = r.alias + r.save() diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index e938621..014949a 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -56,7 +56,6 @@ class Area(models.Model): def __unicode__(self): return self.name - class Road(models.Model): code = models.IntegerField()#primary_key=True)