Skip to content Skip to sidebar Skip to footer

Getting Monday , June 5 , 2016 Instead Of June 5 ,2016 Using Datetimefield

I have an app using Django an my my model has the following field: date = models.DateTimeField(auto_now_add=True,auto_now=False) Using that I get this: June 5, 2016, 9:16 p.m.

Solution 1:

It depends on the context. In a template you can use the date template tags:

<span>{{ my_date|date:"l, F j, Y" }}

or in Python context strftime:

my_date.strftime("%A, %B %W, %Y")

In case you just need the date (without time) you could consider using django's models.DateField instead of models.DateTimeField

Post a Comment for "Getting Monday , June 5 , 2016 Instead Of June 5 ,2016 Using Datetimefield"