Reputation: 1635
I want to print only the date on my Django template. This is my model.
class Comment(models.Model):
name = models.ForeignKey(User)
body = models.TextField()
pub_date = models.DateTimeField(auto_now_add=True)
article = models.ForeignKey(Article)
Now to print both date and time on a template I can use {{object.pub_date}} to print. But I only want to print the date, not the time. Is there a way to do so in Django Templates ?
Upvotes: 2
Views: 3661
Reputation: 22459
{{ object.pub_date|date:"D d M Y" }} {{ object.pub_date|time:"H:i" }}
all options explained: documentation
Upvotes: 18