Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17385 -- Searched the browsed docs version.

  • Loading branch information...
commit 82d1ff051b51561806ed027b92619e64af50bebe 1 parent 6035ad9
@aaugustin aaugustin authored
View
5 django_website/docs/forms.py
@@ -8,11 +8,12 @@
class DocSearchForm(haystack.forms.SearchForm):
def __init__(self, *args, **kwargs):
+ initial_rel = kwargs.pop('release', DocumentRelease.objects.default())
super(DocSearchForm, self).__init__(*args, **kwargs)
self.fields['q'].widget = SearchInput()
self.fields['release'] = DocumentReleaseChoiceField(
queryset = DocumentRelease.objects.all().order_by('version'),
- initial = DocumentRelease.objects.default(),
+ initial = initial_rel,
empty_label = None,
required = False,
)
@@ -29,4 +30,4 @@ def label_from_instance(self, obj):
return obj.human_version
class SearchInput(forms.TextInput):
- input_type = 'search'
+ input_type = 'search'
View
3  django_website/docs/templatetags/docs.py
@@ -11,8 +11,9 @@
def search_form(context, search_form_id='sidebar_search'):
request = context['request']
auto_id = 'id_%s_%%s' % search_form_id
+ release = DocumentRelease.objects.get(version=context['version'])
return {
- 'form': DocSearchForm(initial=request.GET, auto_id=auto_id),
+ 'form': DocSearchForm(initial=request.GET, auto_id=auto_id, release=release),
'search_form_id': search_form_id,
}

1 comment on commit 82d1ff0

@charettes
Collaborator

Hurray!

Please sign in to comment.
Something went wrong with that request. Please try again.