Django Template Filters - timesince and timeuntil

Published: 07 April 2022
on channel: BugBytes
1,393
70

This video showcases two useful template filters built into Django - the timesince filter, and the timeuntil filter.

These can be used with date and time objects to get human-readable text on how long UNTIL or SINCE a particular date.

In the video, we'll show basic usage, as well as how to pass arguments to the filters in order to change the reference point for the comparison (by default, both filters use the current date/time).

▶️ Full Playlist:
   • Python Primers  

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:36 Extending AbstractUser model
02:08 Add User model to admin interface
03:22 Fetching user in view
04:08 Creating HTML table
05:03 Displaying age with timesince filter
06:20 timesince filter with argument
08:57 timeuntil filter

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://www.bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
timesince and timeuntil: https://docs.djangoproject.com/en/4.0...
AbstractUser and customer User model: https://docs.djangoproject.com/en/4.0...

#python #django