From 26554c7f29d83cb5e581b90931d19ac73a320d3a Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 5 Jan 2026 11:47:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=B9=B4=E4=BB=BD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E5=B0=8F=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fzjgact/huodong/templates/base.html | 6 ++---- .../custom_filters.cpython-311.pyc | Bin 2542 -> 2665 bytes .../huodong/templatetags/custom_filters.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fzjgact/huodong/templates/base.html b/fzjgact/huodong/templates/base.html index 1fc896d..b349e34 100644 --- a/fzjgact/huodong/templates/base.html +++ b/fzjgact/huodong/templates/base.html @@ -13,11 +13,9 @@
- 分支机构活动管理 + 分支机构活动管理 {{ ''|get_current_year }}年
- {{ ''|get_current_year }}年 -
- 统计周期:{{ ''|get_statistic_period }} + 统计周期:{{ ''|get_statistic_period }}
diff --git a/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc b/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc index e5930c763b3f8e71a09fb576c9f4bcedfeeeb851..b384739f3fd58626fbf5125f4791de7e2c3ffdf7 100644 GIT binary patch delta 452 zcmaDS{8EH(IWI340}$*tiq3T8*vMzV%EtoaG6V7FG$1j3G7qDcD02-%En}W=2}l?U zvX~~vvx>3RGS)C=F;A{%)nj8R;snY~UdQUJqYq>>Fnr}<;1HUiI#=Q%yV4bQr4J0u ztg<)wggcl!n4j{A_2hKs_2hLhPv&7$Vm$)XK)|Ych*ePQ8ETn;7K5A$2DQvJ%qfi7 zj37=CcMVetQx(u#wJa$>@hYHLEo&Zo4O1-(NEKLywT5LjLkdd`E0AQZVFI(6fh5~p zj#{=FwqOQL_R^z3ja&*q@M7J<=j$flXWKn_HoGbtE5x4%*}Dw&fGUco0tujJMTqh2 y=4=j2MlViAkq-lT7G6V5vJ0LNgp@yMBxP%eNgn}%_$s5?j zxbhfl7-|`77_*orFK5+bWS)GR)md5&sHTD80~dp=(hT2TjUJs&y&k;|y%nVm&Xc{^ zlqBW=<#CxK5lGXqKXxg51@HEh8QnjED^ff~6KfZ)YsNA~@U zev>#<8CfQ4b95~1`oI7q;3{AOV5uT$pfv#G@Kx6U diff --git a/fzjgact/huodong/templatetags/custom_filters.py b/fzjgact/huodong/templatetags/custom_filters.py index 6d778f5..a3fd47c 100644 --- a/fzjgact/huodong/templatetags/custom_filters.py +++ b/fzjgact/huodong/templatetags/custom_filters.py @@ -35,7 +35,11 @@ def get_current_year(value=None): """ 获取当前年份 """ - now = datetime.now() if value is None else value + # 只有当value是datetime对象时才使用它,否则使用当前时间 + if isinstance(value, datetime): + now = value + else: + now = datetime.now() return now.year @@ -48,7 +52,11 @@ def get_statistic_period(value=None): - 在2026年2月,实际统计的是2025年12月至2026年2月 - 以此类推 """ - now = datetime.now() if value is None else value + # 只有当value是datetime对象时才使用它,否则使用当前时间 + if isinstance(value, datetime): + now = value + else: + now = datetime.now() current_year = now.year current_month = now.month