From b6a5bc316646adb4146305eb2f552d54310375f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 4 Sep 2020 19:44:48 +0800 Subject: [PATCH] Revised the regular expression to query by the random primary key in the accounting application. --- accounting/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounting/views.py b/accounting/views.py index ee077c0..7600138 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -780,7 +780,7 @@ def search(request: HttpRequest) -> HttpResponse: | Q(transaction__notes__icontains=query) if re.match("^[0-9]+(?:\\.[0-9]+)?$", query): conditions = conditions | Q(amount=Decimal(query)) - if re.match("^[0-9]{9}$", query): + if re.match("^[1-9][0-8]{9}$", query): conditions = conditions\ | Q(pk=int(query))\ | Q(transaction__pk=int(query))\