Mercurial > public > sg101
comparison custom_search/forms.py @ 1034:2f36abf65a62
Fix UnicodeEncodeError issue in custom search form.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Dec 2015 15:28:16 -0600 |
parents | 6cc9221d04a7 |
children | 829d3b7fc0f7 |
comparison
equal
deleted
inserted
replaced
1033:217084b6e0a0 | 1034:2f36abf65a62 |
---|---|
95 | 95 |
96 # Note that in Haystack 2.x content is untrusted and is automatically | 96 # Note that in Haystack 2.x content is untrusted and is automatically |
97 # auto-escaped for us. | 97 # auto-escaped for us. |
98 # | 98 # |
99 # Gather regular search terms | 99 # Gather regular search terms |
100 terms = ' '.join(self.cleaned_data['q'].split()) | 100 terms = u' '.join(self.cleaned_data['q'].split()) |
101 | 101 |
102 # Exact words or phrases: | 102 # Exact words or phrases: |
103 exact = self.cleaned_data['exact'].strip() | 103 exact = self.cleaned_data['exact'].strip() |
104 if exact: | 104 if exact: |
105 exact = '"{}"'.format(exact) | 105 exact = u'"{}"'.format(exact) |
106 | 106 |
107 # Exclude terms: | 107 # Exclude terms: |
108 exclude = ["-{}".format(term) for term in self.cleaned_data['exclude'].split()] | 108 exclude = [u"-{}".format(term) for term in self.cleaned_data['exclude'].split()] |
109 exclude = ' '.join(exclude) | 109 exclude = u' '.join(exclude) |
110 | 110 |
111 query = ' '.join([terms, exact, exclude]).strip() | 111 query = u' '.join([terms, exact, exclude]).strip() |
112 logger.debug("auto_query: %s", query) | 112 logger.debug("auto_query: %s", query) |
113 | 113 |
114 sqs = self.searchqueryset.auto_query(query) | 114 sqs = self.searchqueryset.auto_query(query) |
115 | 115 |
116 if self.load_all: | 116 if self.load_all: |