Skip to content

Commit 0a34f44

Browse files
authored
Show full month name in search results (#548)
1 parent 4bc4e27 commit 0a34f44

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

blog/search.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import time
22
import json
33
import re
4+
import calendar
45
from django.db import models
56
from django.db.models.functions import TruncYear, TruncMonth
67
from django.contrib.postgres.search import SearchQuery, SearchRank
78
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
89
from django.http import HttpResponse, Http404
910
from django.shortcuts import render
1011
from blog.models import Entry, Blogmark, Quotation, Note, Tag, load_mixed_objects
11-
from .views import MONTHS_3_REV_REV
1212
from spellchecker import SpellChecker
1313
import datetime
1414

@@ -234,9 +234,11 @@ def make_queryset(klass, type_name):
234234
"year": selected_year,
235235
"month": selected_month,
236236
"type": selected_type,
237-
"month_name": MONTHS_3_REV_REV.get(
238-
selected_month and int(selected_month) or "", ""
239-
).title(),
237+
"month_name": (
238+
calendar.month_name[int(selected_month)]
239+
if selected_month.isdigit()
240+
else ""
241+
),
240242
"from_date": from_date,
241243
"to_date": to_date,
242244
}

blog/tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,17 @@ def test_top_tags_page(self):
392392
self.assertFalse(any(info["tag"].tag == "tag1" for info in tags_info))
393393
latest = Tag.objects.get(tag="tag11").entry_set.order_by("-created")[0].title
394394
self.assertContains(response, latest)
395+
396+
def test_search_title_displays_full_month_name(self):
397+
tag = Tag.objects.create(tag="llm-release")
398+
entry = EntryFactory(
399+
created=datetime.datetime(2025, 7, 1, tzinfo=datetime.timezone.utc)
400+
)
401+
entry.tags.add(tag)
402+
response = self.client.get(
403+
"/search/?tag=llm-release&year=2025&month=7"
404+
)
405+
self.assertContains(
406+
response,
407+
"Posts tagged llm-release in July, 2025",
408+
)

0 commit comments

Comments
 (0)