Mercurial > public > sg101
comparison custom_search/forms.py @ 581:ee87ea74d46b
For Django 1.4, rearranged project structure for new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 17:10:48 -0500 |
parents | gpp/custom_search/forms.py@3b30286adba5 |
children | 99d7bf8cd712 |
comparison
equal
deleted
inserted
replaced
580:c525f3e0b5d0 | 581:ee87ea74d46b |
---|---|
1 """ | |
2 This module contains custom forms to tailor the Haystack search application to | |
3 our needs. | |
4 | |
5 """ | |
6 from django import forms | |
7 from haystack.forms import ModelSearchForm | |
8 | |
9 | |
10 MODEL_CHOICES = ( | |
11 ('forums.topic', 'Forum Topics'), | |
12 ('forums.post', 'Forum Posts'), | |
13 ('news.story', 'News Stories'), | |
14 ('bio.userprofile', 'User Profiles'), | |
15 ('weblinks.link', 'Links'), | |
16 ('downloads.download', 'Downloads'), | |
17 ('podcast.item', 'Podcasts'), | |
18 ('ygroup.post', 'Yahoo Group Archives'), | |
19 ) | |
20 | |
21 | |
22 class CustomModelSearchForm(ModelSearchForm): | |
23 """ | |
24 This customized ModelSearchForm allows us to explictly label and order | |
25 the model choices. | |
26 | |
27 """ | |
28 q = forms.CharField(required=False, label='', | |
29 widget=forms.TextInput(attrs={'class': 'text', 'size': 48})) | |
30 | |
31 def __init__(self, *args, **kwargs): | |
32 super(CustomModelSearchForm, self).__init__(*args, **kwargs) | |
33 self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES, | |
34 label='', widget=forms.CheckboxSelectMultiple) |