I want to display tomorrow's date. I am using a generic ListView
.
Today's date is easy via:
{% now "jS F Y H:i" %}
Hope this solution will be also helpful. In your template tag register new template
import datetime
register = template.Library()
@register.filter()
def addDays(days):
newDate = datetime.date.today() + datetime.timedelta(days=days)
return newDate
Then in template you can use it in a different way like:
A custom template tag would do the trick here.
from django import template
from datetime import datetime
register = template.Library()
@register.simple_tag
def tomorrow(format):
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
return tomorrow.strftime(format)
Remember to use the format as followed by datetime
module in python.
Then in template
{% tomorrow "%Y-%m-%d %H:%M" %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With