This commit is contained in:
d42 2018-04-27 23:23:40 +02:00
parent cbc3a79138
commit b8677eebec
3 changed files with 5 additions and 11 deletions

View File

@ -10,10 +10,6 @@
<button class="btn btn-primary" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
<!-- <div class="text&#45;right"> -->
<!-- <input type="checkbox" id="smartsearch" name="smartsearch"> -->
<!-- <label for="smartsearch">SmartSearch</label> -->
<!-- </div> -->
</form>
</div>
</div>

View File

@ -5,7 +5,6 @@ from django.contrib.postgres.search import SearchVector, TrigramSimilarity
from django.http import Http404, JsonResponse
from django.contrib.admin.models import LogEntry
from django_select2.views import AutoResponseView
from django.db.models import Q
from django.db import connection
from storage.models import Item, Label
@ -122,7 +121,11 @@ class PropSelectView(AutoResponseView):
self.term = kwargs.get('term', request.GET.get('term', ''))
# context = self.get_context_data()
with connection.cursor() as c:
c.execute("select e from (select skeys(props) as e, count(skeys(props)) as e_count from storage_item group by e order by e_count desc) as xD where e like %s limit 10;", ['%' + self.term + '%'])
c.execute("""
select e from (
select skeys(props) as e, count(skeys(props)) as e_count
from storage_item group by e order by e_count desc) as xD
where e like %s limit 10;""", ['%' + self.term + '%'])
props = c.fetchall()
return JsonResponse({

View File

@ -66,10 +66,5 @@
</script>
<script>
django.jQuery('a.hs-add-row').on('click', console.log);
django.jQuery(function() { initDjangoHStoreWidget('{{ field_name }}') });
// function(e) {
// $('.django-select2').select2();
// });
</script>