I lately added slug fields to my MySQL database models (I'm not sure why it did not happen to me to get this done earlier). Now I've got a couple of blank slug fields during my database. I incorporated 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 wish to write something to populate each record during my models. Any suggestions on which code I'm able to email possibly get it cycle through my models/records and populate the slugs?

One more complication (though I am unsure I care a lot relating to this). I've got a area in every model:

last_modified = models.DateTimeField("Last Modified", auto_now=True)

I'd rather not trigger this since the records aren't truly being modified. Can One populate the slugs without upgrading the final_modified fields?

Well whether it is not lots of data, and it's really a one-time factor, simply do it within the spend:

$ python manage.py shell
>>> from my_app.models import Test
>>> for obj in Test.objects.all():
>>>     obj.save()

If you are planning to get this done a great deal, write a custom management command that performs this.

For your auto_now problem, because of this , I have stopped using auto_now and auto_now_add. Each time I have used them, I have always ripped them out later. Actually, the Django designers have stated they consider them deprecated plus they most likely is going to be removed later on. I'd just edit the origin code and take away that option before you run your command, then either add it in or change it with custom save() logic.