Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ locale/*/LC_MESSAGES/django.mo
djangoproject/cache
djangoproject/static/css/*.map
djangoproject/static/css/*.css
/venv
12 changes: 10 additions & 2 deletions docs/templates/docs/search_form.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{% load i18n %}
<search class="search form-input" aria-labelledby="docs-search-label">
<form action="{% url 'document-search' version=version lang=lang host 'docs' %}">
<label id="docs-search-label" class="visuallyhidden" for="{{ form.q.id_for_label }}">{{ form.q.field.widget.attrs.placeholder }}</label>
<form action="{% url 'document-search' version=version lang=lang host 'docs' %}" method="get">
<label id="docs-search-label" class="visuallyhidden" for="{{ form.q.id_for_label }}">
{{ form.q.field.widget.attrs.placeholder }}
</label>

{{ form.q }}

{# Preserve the selected category across searches #}
{% if category %}
<input type="hidden" name="category" value="{{ category }}">
{% endif %}

<button type="submit">
<i class="icon icon-search" aria-hidden="true"></i>
<span class="visuallyhidden">{% translate "Submit" %}</span>
Expand Down
5 changes: 5 additions & 0 deletions docs/templatetags/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ def search_form(context):
context["version"],
context["lang"],
)

# Pass the selected category from GET parameters
selected_category = request.GET.get("category", "")

return {
"form": DocSearchForm(request.GET, release=release),
"version": context["version"],
"lang": context["lang"],
"category": selected_category, # <- new line
}


Expand Down