diff options
author | luxagraf <sng@luxagraf.net> | 2017-07-16 09:40:48 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2017-07-16 09:40:48 -0600 |
commit | d295b55359e0f507775aba62f29a76de077bfca1 (patch) | |
tree | afc327d4193dabfbddd50b614e1dd1577b230362 /app/utils | |
parent | a4335acd6312620a40898be33042e3d4de762f0b (diff) |
Updated to django autocomplete v3
Diffstat (limited to 'app/utils')
-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 |