Django - Get only date from datetime.strptime

I think you need date object not datetime. Try converting datetime to date using date() method on datetime object

from datetime import datetime
datetime.strptime('2014-12-04', '%Y-%m-%d').date()

Iazy functor's answer is very helpful. For people who want to use it as template tag:

from django import template
from datetime import datetime

register = template.Library()

@register.filter(name='todate')
def convert_str_date(value):
    return datetime.strptime(value, '%Y-%m-%d').date()

Then import your template.py in your HTML and use it as:

{{ date_in_str|todate }}

Output: 2021.01.22

If you want to change the date format:

{{ date_in_str|todate|date:"d N Y" }}

Output: 22 Jan. 2021