from datetime import datetime
dt = datetime.now()
from django.utils.dateformat import DateFormat
from django.utils.formats import get_format
df = DateFormat(dt)
df.format(get_format('DATE_FORMAT'))
df.format('Y-m-d')
Django: how to get format date in views?