aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/info/forms.py
diff options
context:
space:
mode:
Diffstat (limited to '97suifangqa/apps/info/forms.py')
-rw-r--r--97suifangqa/apps/info/forms.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/97suifangqa/apps/info/forms.py b/97suifangqa/apps/info/forms.py
new file mode 100644
index 0000000..717431d
--- /dev/null
+++ b/97suifangqa/apps/info/forms.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+from haystack.forms import SearchForm
+
+from .models import Query
+from .utils import split_word
+
+class QuerySearchForm(SearchForm):
+ u'''
+ 问题查询表单,主要完成两个工作:
+ 1. 指定查询的model为Query
+ 2. 重载clean_q,对查询语句进行分词
+ '''
+
+ def __init__(self,*args, **kwargs):
+ u'''
+ 在__init__中指定查询的model为Query
+ '''
+ super(QuerySearchForm, self).__init__(*args, **kwargs)
+ self.searchqueryset = self.searchqueryset.models(Query)
+
+ def clean_q(self):
+ q = self.cleaned_data['q']
+ return split_word(q)