1

the title probably seems very confusing but I will explain it. I am trying to make a feature in my Django rest framework project of which when you sign up it calculates your age then if you are old enough your account is made but if you are not it gives an error of you are not old enough.

so my 2 questions are:

  1. how would you calculate a users age using their date of birth

  2. how would you only create account which have users over the age(in my case I would like to make the threshold 13)

I have seen another question on stack overflow here. I added the calculation on the top answer to my models.py but It gives an error in self.birthday(which in the answer would be date_of_birth) saying

Unexpected field type(s):
(DateField)
Possible type(s):
(timedelta)
(date)
aarush_s
  • 91
  • 1
  • 1
  • 7
  • 1
    Have you tried `field_level validation` in the serializer class. – Manish Shah Apr 16 '21 at 13:36
  • @ManishShah I haven't tried that. Can you elaborate on what the``` field_level validation ```in a serialised class will do as I don't really understand – aarush_s Apr 20 '21 at 20:01

0 Answers0