Hi Everyone,
My model is working just fine, my only problem is that the field “age” and “id_code” that I create using function don’t appear in my admin area while the other field are there.
What could be the problem? Thank you all
class UserInformation(models.Model):
gender_choice = [('m', 'Male'),('f', 'Female')]
id_code = models.CharField(max_length=120)
gender = models.CharField(max_length=120, choices=gender_choice)
birthdate = models.DateField()
age = models.CharField(null=True, max_length=2)
def __str__(self):
return self.first_name[:2].lower() + '_' + self.last_name[:2].lower()
def age(self):
age = datetime.now().year - int(self.birthdate.year)
return age
def id_code(self):
id_code = self.first_name[:2].lower() + '_' + self.last_name[:2].lower()
return id_code