I’m currently using the timeuntil tag to show an items expiration date. It’s currently spitting out…
{{rental_till|timeuntill}}
Which produces…
3 months, 1 week
Is it possible to get it to just show, the months, for example? Or any type of finer control over the output format, similar to the date tags.
To only show months, you could write a simple template filter that splits the string on the comma, and returns the first item of the resulting list. The filter code would look like this:
Then in your template:
{{rental_till|timeuntil|split_timeuntil}}However, the
timeuntilfilter does not have the kind of formattingdatehas. You can easily create a custom filter that returns the format you want by copying thetimeutilcode indjango/template/defaultfilters.pyanddjango/utils/timesince.py.