Storing the age in a field looks like a bad idea: if the record is not updated somehow, or the signals do not run, then the age can get outdated. For example a person might be stored in the database, but if you never save that object again, after the person's birthday, it will still show the old age.
Therefore it is better not to store this in a field, and use for example a property to determine this when that is necessary, you can define such model with:
from django.utils.timezone import now
class User(models.Model):
# …
date_of_birth = models.DateField()
# no age or is_adult field
@property
def age(self):
today = now().date()
dob = self.date_of_birth
return today.year - dob.year - (today.timetuple()[1:3] < dob.timetuple()[1:3])
@property
def is_adult(self):
return self.age >= 18
This will thus make it possible to access .age
and .is_adult
for a User
object.