Unless you have a good reason to write one of your own, I suggest using the slugify() method provided by django, and do something along the lines of:
def save(self, **kwargs):
from django.utils.text import slugify
self.slug = slugify(self.user.username)
super(UserProfile, self).save()
This assumes you're using 1.6. The only thing that MIGHT have changed is where you import from. They like to change those things fairly often I've noticed.
Docs: https://docs.djangoproject.com/en/dev/ref/utils/#django-utils-text