I recently added slug fields to my MySQL database models (I don't know why it didn't occur to me to do this earlier). Now I have a bunch of blank slug fields in my database. I included a save definition in each model
class test(models.Model):
q = models.CharField(max_length=30)
s = models.SlugField()
def save(self, *args, **kwargs):
self.s = slugify(self.q)
super(test, self).save(*args, **kwargs)
Now I want to write something to populate each record in my models. Any suggestions on what code I can write to perhaps have it cycle through all my models/records and populate the slugs?
An additional complication (though I'm not sure I care a ton about this). I have a field in each model:
last_modified = models.DateTimeField("Last Modified", auto_now=True)
I'd rather not trigger this because the records aren't really being modified. Can I populate the slugs without updating the last_modified fields?