From 24bcc589b4d29b977787fea448fc0c8cede3f419 Mon Sep 17 00:00:00 2001 From: Bob <1397910458@qq.com> Date: Tue, 13 Oct 2020 14:46:15 +0800 Subject: [PATCH] #zhuce --- dashboard/templates/dashboard/register.html | 96 +++++++++++++++---- .../dashboard/results_by_keywords.html | 24 +++++ dashboard/urls.py | 2 +- dashboard/views.py | 41 ++++---- 4 files changed, 125 insertions(+), 38 deletions(-) create mode 100644 dashboard/templates/dashboard/results_by_keywords.html diff --git a/dashboard/templates/dashboard/register.html b/dashboard/templates/dashboard/register.html index 8610b58..1704a74 100644 --- a/dashboard/templates/dashboard/register.html +++ b/dashboard/templates/dashboard/register.html @@ -69,10 +69,26 @@ {# #} {#

#}

-

- + +
+
+ {#
#} + {#
#} + {#
loading...
#} + {#
#} + {#

{{ points.point_lat }}

#} + {#

{{ points.point_lon }}

#} + {#
#} + {#
#} + {#
#}

+ diff --git a/dashboard/urls.py b/dashboard/urls.py index 348931f..3b8ba25 100644 --- a/dashboard/urls.py +++ b/dashboard/urls.py @@ -18,6 +18,6 @@ urlpatterns = [ path('get/town/',views.get_town), path('get/village/',views.get_village), #单位搜索 - path('get/organization/',views.get_organization) + path('get/organization/',views.get_organization,name='get-organization') ] diff --git a/dashboard/views.py b/dashboard/views.py index 1ba1d63..b991a35 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -219,21 +219,26 @@ def get_village(request): def get_organization(request): - q = request.GET.get('q') - organization = Organization.objects.filter(name__contains=q)[:20] - res = [] - for o in organization: - d = dict() - d['name'] = o.name - d['province'] = Area_code_2020.objects.get(code=o.province).name - if o.cities: - d['cities'] = Area_code_2020.objects.get(code=o.cities).name - else: - d['cities'] = '' - if o.district: - d['district'] = Area_code_2020.objects.get(code=o.district).name - else: - d['district'] = '' - res.append(d) - print(res) - return HttpResponse(json.dumps(res)) + # q = request.GET.get('q') + # organization = Organization.objects.filter(name__contains=q)[:20] + # res = [] + # for o in organization: + # d = dict() + # d['name'] = o.name + # d['province'] = Area_code_2020.objects.get(code=o.province).name + # if o.cities: + # d['cities'] = Area_code_2020.objects.get(code=o.cities).name + # else: + # d['cities'] = '' + # if o.district: + # d['district'] = Area_code_2020.objects.get(code=o.district).name + # else: + # d['district'] = '' + # res.append(d) + # print(res) + # return HttpResponse(json.dumps(res)) + keywords = request.GET.get('keyword') + if len(keywords) != 0: + topten_list = Organization.objects.filter(Q(name__contains=keywords)) + print(str(topten_list)) + return render(request, 'dashboard/results_by_keywords.html', {'topten_list': topten_list})