Skip to content

Commit c548ba8

Browse files
author
Emmanouil Konstantinidis
committed
Fix search
1 parent 7196819 commit c548ba8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

rest_framework_docs/templates/rest_framework_docs/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
<!-- Collect the nav links, forms, and other content for toggling -->
4141
<div class="collapse navbar-collapse" id="drfdoc-navbar">
42-
<form class="navbar-form navbar-right" role="search">
42+
<form method="get" action="." class="navbar-form navbar-right" role="search">
4343
<div class="form-group">
44-
<input type="text" class="form-control" placeholder="Search">
44+
<input type="text" class="form-control" name="search" value="{{ query }}" placeholder="Search">
4545
</div>
4646
</form>
4747
<ul class="nav navbar-nav navbar-right">

rest_framework_docs/templates/rest_framework_docs/home.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ <h4 class="panel-title title">
7070
</div>
7171

7272
{% endfor %}
73-
{% else %}
73+
{% elif not query %}
7474
<h2 class="text-center">There are currently no api endpoints to document.</h2>
75+
{% else %}
76+
<h2 class="text-center">No endpoints found for {{ query }}.</h2>
7577
{% endif %}
7678

7779
{% endblock %}

rest_framework_docs/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_context_data(self, **kwargs):
1717
docs = ApiDocumentation()
1818
endpoints = docs.get_endpoints()
1919

20-
query = self.request.GET.get("q", None)
20+
query = self.request.GET.get("search", "")
2121
if query and endpoints:
2222
endpoints = [endpoint for endpoint in endpoints if query in endpoint.path]
2323

0 commit comments

Comments
 (0)