Skip to content

Feat: validate district URL and add 404 handler #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pems/districts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
URLConf for the districts app.
"""

from django.urls import path
from django.urls import path, re_path

from pems.districts import views

app_name = "districts"
urlpatterns = [
# /districts
path("", views.IndexView.as_view(), name="index"),
path("<int:district_number>", views.DistrictView.as_view(), name="district"),
re_path(r"^(?P<district_number>([1-9]|1[0-2]))$", views.DistrictView.as_view(), name="district"),
]
2 changes: 1 addition & 1 deletion pems/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _filter_empty(ls):
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [os.path.join(BASE_DIR, "pems", "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
7 changes: 7 additions & 0 deletions pems/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "core/base.html" %}
{% block headline %}
Sorry! We can’t find that page.
{% endblock headline %}
{% block inner-content %}
<p>The page you are looking for might be somewhere else or may not exist anymore.</p>
{% endblock inner-content %}
Loading