Delta日期在Django模板中

时间:2017-09-06 06:42:27

标签: html django django-templates

我创建了一个视图,它将项目的两个日期传递给html模板。我在html模板中得到了两个日期,如下所示:

{% for item in items %}
{{ item.form_date }}
{{ item.to_date }}
      # I need the difference between the dates here....
{% endfor %}

我不想从视图中返回差异数据,但希望在html中看到日期的增量。我该怎么办?

1 个答案:

答案 0 :(得分:2)

您可以尝试timesince

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/foo/bar/gcc-6.2.0/gcc/libexec/gcc/x86_64-redhat-linux/6.2.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../gcc-6.2.0/configure --prefix=/foo/bar/gcc-6.2.0/gcc --build=x86_64-redhat-linux --disable-multilib --enable-languages=c,c++,fortran --with-default-libstdcxx-abi=gcc4-compatible --enable-bootstrap --enable-threads=posix --with-long-double-128 --enable-long-long --enable-lto --enable-__cxa_atexit --enable-gnu-unique-object --with-system-zlib --enable-gold
Thread model: posix
gcc version 6.2.0 (GCC)