convert string to date django
from django.utils.dateparse import parse_date, parse_datetime
# For only Date
date_str = "2021-04-07"
date = parse_date(date_str)
# For DateTime
datetime_str = "2021-09-10T18:40:54"
date = parse_date(datetime_str)
OR
date_str = "2021-04-07"
datetime.datetime.strptime(date_str, "%Y-%m-%d").date()