set date format in Timezone aware date object

493 views Asked by At

I want to get date in this format %d-%m-%Y" in following code:

from django.utils.timezone import localtime, now
from freezegun import freeze_time
.....
    @freeze_time("12-02-2012")
    def setUp(self):
        self.current_date = localtime(now()).date()

In my settings.py I have these settings:

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Dhaka'

USE_I18N = True

USE_L10N = True

USE_TZ = True

DATE_INPUT_FORMATS = ("%d-%m-%Y", )
DATE_FORMAT = ("%d-%m-%Y", )

But now I am getting date 2012-12-02. So what is the correct way to get date in %d-%m-%Y format in test client.

0

There are 0 answers