Added to search by the month in the search query in the accounting application.

This commit is contained in:
依瑪貓 2020-09-04 19:44:08 +08:00
parent c1446df532
commit 7f8375bfe7

View File

@ -795,6 +795,13 @@ def search(request: HttpRequest) -> HttpResponse:
| Q(transaction__date__year=date.year)
except ValueError:
pass
try:
date = datetime.datetime.strptime(query, "%Y/%m")
conditions = conditions\
| (Q(transaction__date__year=date.year)
& Q(transaction__date__month=date.month))
except ValueError:
pass
try:
date = datetime.datetime.strptime(query, "%m/%d")
conditions = conditions\