diff options
Diffstat (limited to 'app/utils/views.py')
-rw-r--r-- | app/utils/views.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/utils/views.py b/app/utils/views.py index c5f3f59..fe0db4b 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -35,3 +35,20 @@ def insert_image(request): ) return render_to_response('admin/insert_images.html', {'object_list': object_list, 'textarea_id': request.GET['textarea']}, context_instance=RequestContext(request)) + +from taggit.models import Tag + +from dal import autocomplete + +class TagAutocomplete(autocomplete.Select2QuerySetView): + def get_queryset(self): + # Don't forget to filter out results depending on the visitor ! + if not self.request.user.is_authenticated(): + return Tag.objects.none() + + qs = Tag.objects.all() + + if self.q: + qs = qs.filter(name__istartswith=self.q) + + return qs |