forked from marcopoli/PugliaeventiRecommender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlookups.py
26 lines (18 loc) · 795 Bytes
/
lookups.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ajax_select import register, LookupChannel
from .models import Comune
@register('cities')
class TagsLookup(LookupChannel):
model = Comune
def check_auth(self, request):
return True
def get_query(self, q, request):
return self.model.objects.filter(nome__icontains=q).order_by('nome')
def get_result(self, obj):
""" result is the simple text that is the completion of what the person typed """
return obj.nome
def format_match(self, obj):
""" (HTML) formatted item for display in the dropdown """
return self.format_item_display(obj)
def format_item_display(self, item):
""" (HTML) formatted item for displaying item in the selected deck area """
return u"<span class='tag'>%s</span>" % item.nome