forms.py 532 Bytes
Newer Older
Gabriel Detraz's avatar
Gabriel Detraz committed
1 2 3
from django.db.models import Q
from simple_search import BaseSearchForm

Gabriel Detraz's avatar
Gabriel Detraz committed
4
from users.models import User
Gabriel Detraz's avatar
Gabriel Detraz committed
5 6 7 8 9 10 11 12 13 14 15 16

class UserSearchForm(BaseSearchForm):
    class Meta:
        base_qs = User.objects
        search_fields = ('^name', 'description', 'specifications', '=id') 

        # assumes a fulltext index has been defined on the fields
        # 'name,description,specifications,id'
        fulltext_indexes = (
            ('name', 2), # name matches are weighted higher
            ('name,description,specifications,id', 1),
        )