I have a User model. What I want is when a user registers, the slack field is filled with data from a function which uses users email as a parameter. (Basically slack should be something like "DS8ds9D" which is generated from email.
I have the function that does that "get_slack(email)" which I know works if run outside model with an email. The error I get is when I try to "makemigrations" saying the email from "get_slack(email)" is null.
class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField(default=timezone.now)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
slack = models.CharField(max_length=255, default=get_slack(email))
I think it is clear what I am trying to establish however my method using "default" may not be appropriate. Any suggestions? Thanks.