def test_or_empty(self): autocomplete_list = AutocompleteList() autocomplete_list.model = RalphUser result = autocomplete_list.get_query_filters( RalphUser.objects.all(), 'first_name_1 last_name_2', ['username', 'first_name', 'last_name']) self.assertEqual(len(result), 0)
def test_not_or_empty(self): autocomplete_list = AutocompleteList() autocomplete_list.model = Region result = autocomplete_list.get_query_filters( Region.objects.all(), 'pl de', ['name'] ) self.assertEqual(len(result), 0)
# -*- coding: utf-8 -*- from django.conf.urls import url from django.contrib.auth.decorators import login_required from ralph.admin.autocomplete import AutocompleteList from ralph.admin.sites import ralph_site urlpatterns = [ url(r'^(?P<app>\w+)/(?P<model>\w+)/(?P<field>\w+)/autocomplete$', login_required(ralph_site.admin_view(AutocompleteList.as_view())), name='autocomplete-list'), ]