I want username field automatically filled with this:
username = email[0] + str(id)
where id is the id of the user object
Is it possible ?
Thanks :)
I want username field automatically filled with this:
username = email[0] + str(id)
where id is the id of the user object
Is it possible ?
Thanks :)
You can use hooks to achieve this.
It would be something like this (not tested):
from django.db import models
class User(models.Model):
email = model.EmailField()
username = models.CharField(max_length=80)
def save(self):
if not self.id:
self.username = ''
super(User, self).save()
self.username = "%i%s" % (self.id, self.email)
super(User, self).save()