I use UserProfile model for keeping additional info about user and one of the fields is subdomain variable that is by default should be set to username. Here is UserProfile model:
class UserProfile(models.Model):
theme = models.ForeignKey(Theme, unique=True, null=True)
user = models.ForeignKey(User, unique=True)
subdomain = models.CharField(default=self.user.username, max_length=30)
I implemented Django signals feature to create UserProfile model instance automatically on user creation. Now I need to set subdomain variable to username. How can I do this?