[Answered ]-How to get only month name and total in Django

1๐Ÿ‘

โœ…

Iโ€™m assuming getting the total/count is not a big issue here.

Since you already have the datetime object ie.: (2021, 3, 1,0,0, โ€ฆ) , you can extract the Month name using obj.strftime("%B")

Like this:

>>> date_obj
datetime.datetime(2021, 3, 1, 0, 0, tzinfo=<DstTzInfo 'Asia/Dhaka' LMT+6:02:00 STD>)
>>> month = date_obj.strftime("%B")
>>> month
'March'

You can also get short version of months, weekdays etc : Python documentation: strftime

๐Ÿ‘คNeeraj

Leave a comment