Skip to content

Commit 9876bfc

Browse files
committed
feat: validate district number in district URL pattern
validate the URL pattern to only allow 1-12 for district number
1 parent 6e5bc91 commit 9876bfc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pems/districts/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
URLConf for the districts app.
33
"""
44

5-
from django.urls import path
5+
from django.urls import path, re_path
66

77
from pems.districts import views
88

99
app_name = "districts"
1010
urlpatterns = [
1111
# /districts
1212
path("", views.IndexView.as_view(), name="index"),
13-
path("<int:district_number>", views.DistrictView.as_view(), name="district"),
13+
re_path(r"^(?P<district_number>([1-9]|1[0-2]))$", views.DistrictView.as_view(), name="district"),
1414
]

0 commit comments

Comments
 (0)