Showing
10 changed files
with
73 additions
and
20 deletions
.vscode/launch.json
0 → 100644
1 | +{ | ||
2 | + // Use IntelliSense to learn about possible attributes. | ||
3 | + // Hover to view descriptions of existing attributes. | ||
4 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
5 | + "version": "0.2.0", | ||
6 | + "configurations": [ | ||
7 | + { | ||
8 | + "type": "chrome", | ||
9 | + "request": "launch", | ||
10 | + "name": "Launch Chrome against localhost", | ||
11 | + "url": "http://127.0.0.1:8000/market_analysis/returnfarm?maptype=9&contenttype=edu", | ||
12 | + "webRoot": "${workspaceFolder}" | ||
13 | + } | ||
14 | + ] | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -11,23 +11,33 @@ | ... | @@ -11,23 +11,33 @@ |
11 | </head> | 11 | </head> |
12 | 12 | ||
13 | <body> | 13 | <body> |
14 | - <h1><a href="http://127.0.0.1:8000/market_analysis/maplist">Statistics on Return Farm Project</a></h1> | 14 | + <!--body--> |
15 | - <br> | 15 | + <div id="bodyWrap"> |
16 | - <h3>농산물 시장 유통에 대한 통계분석 입니다.</h3> | 16 | + <div id="header"> |
17 | - <br> | 17 | + <h1><a href="/market_analysis/maplist">Statistics on Return Farm Project</a></h1> |
18 | - | 18 | + <br> |
19 | - <ul class="nav justify-content-center"> | 19 | + <h3>농산물 시장 유통에 대한 통계분석 입니다.</h3> |
20 | + <br> | ||
21 | + </div> | ||
22 | + <div id="menubar"> | ||
23 | + <ul class="nav justify-content-center"> | ||
20 | <li class="nav-item"> | 24 | <li class="nav-item"> |
21 | - <a class="nav-link active" href="http://127.0.0.1:8000/market_analysis/market">Market</a> | 25 | + <a class="nav-link active" href="/market_analysis/market">Market</a> |
22 | </li> | 26 | </li> |
23 | <li class="nav-item"> | 27 | <li class="nav-item"> |
24 | - <a class="nav-link" href="http://127.0.0.1:8000/market_analysis/population">Population</a> | 28 | + <a class="nav-link" href="/market_analysis/population">Population</a> |
25 | </li> | 29 | </li> |
26 | <li class="nav-item"> | 30 | <li class="nav-item"> |
27 | - <a class="nav-link" href="http://127.0.0.1:8000/market_analysis/returnfarm">Return Farm</a> | 31 | + <a class="nav-link" href="/market_analysis/returnfarm">Return Farm</a> |
28 | </li> | 32 | </li> |
29 | </ul> | 33 | </ul> |
30 | - | ||
31 | </div> | 34 | </div> |
35 | + </div> | ||
36 | + <!--content--> | ||
37 | + <div id="contentWrap"> | ||
38 | + <h6> | ||
39 | + explain 들어가는 부분 | ||
40 | + </h6> | ||
41 | + </div> | ||
32 | </body> | 42 | </body> |
33 | </html> | 43 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | from django.conf.urls import url | 1 | from django.conf.urls import url |
2 | +from django.urls import path | ||
2 | from . import views | 3 | from . import views |
3 | 4 | ||
4 | urlpatterns = [ | 5 | urlpatterns = [ |
5 | - url('returnfarm/<int:maptype>', views.returnfarm), | 6 | + url('returnfarm', views.returnfarm, name="returnfarm"), |
6 | - url('population', views.population), | 7 | + url('population', views.population, name="population"), |
7 | url('market', views.market), | 8 | url('market', views.market), |
8 | url('', views.main), | 9 | url('', views.main), |
9 | ] | 10 | ] |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | +#-*- coding:utf-8 | ||
2 | + | ||
1 | from django.shortcuts import render | 3 | from django.shortcuts import render |
2 | -from django.db.models import Count | 4 | +from django.db.models import Count, Max |
5 | +from urllib.request import urlopen | ||
3 | from .models import RT_edu, Maps, RT_agri_policy | 6 | from .models import RT_edu, Maps, RT_agri_policy |
7 | +from bs4 import BeautifulSoup | ||
8 | +import pandas as pd | ||
4 | 9 | ||
5 | # Create your views here. | 10 | # Create your views here. |
6 | 11 | ||
7 | -def dbselect(contenttype, maptype): | 12 | +def returnfarm_dbselect(contenttype, maptype): |
8 | if maptype == 9: | 13 | if maptype == 9: |
9 | mapt = 'city' | 14 | mapt = 'city' |
10 | elif maptype == 10: | 15 | elif maptype == 10: |
11 | mapt = 'cntr' | 16 | mapt = 'cntr' |
12 | - | ||
13 | if contenttype=='policy': | 17 | if contenttype=='policy': |
14 | myrtrn = RT_agri_policy.objects.values(mapt).annotate(count=Count(mapt)) | 18 | myrtrn = RT_agri_policy.objects.values(mapt).annotate(count=Count(mapt)) |
15 | return myrtrn | 19 | return myrtrn |
... | @@ -17,18 +21,41 @@ def dbselect(contenttype, maptype): | ... | @@ -17,18 +21,41 @@ def dbselect(contenttype, maptype): |
17 | myrtrn = RT_edu.objects.values(mapt).annotate(count=Count(mapt)) | 21 | myrtrn = RT_edu.objects.values(mapt).annotate(count=Count(mapt)) |
18 | return myrtrn | 22 | return myrtrn |
19 | 23 | ||
24 | +# 공공데이터 불러오는 부분 | ||
25 | +def publicdata(): | ||
26 | + # 통계청 귀농가구원의 시도별, 시군별, 연령별 | ||
27 | + url = 'http://kosis.kr/openapi/statisticsData.do?method=getList&apiKey=M2I3MWFhNzE2MjlkYjhhNzgwNWFjNWQ3MGU0MzY5Y2Y=&format=json&jsonVD=Y&userStatsId=tjsdk3105/101/DT_1A02003/2/1/20200529160216&prdSe=Y&newEstPrdCnt=1' | ||
28 | + data = urlopen(url).read().decode('utf8') | ||
29 | + return data | ||
30 | + | ||
20 | def main(request): | 31 | def main(request): |
21 | return render(request, 'main.html') | 32 | return render(request, 'main.html') |
22 | 33 | ||
23 | -def returnfarm(request, maptype): | 34 | +def returnfarm(request): |
24 | - mapp = Maps.objects.get(id=maptype) | 35 | + try: |
25 | - mapp = mapp.mapdata | 36 | + maptype = request.GET['maptype'] |
26 | - exportdatas = dbselect('policy', maptype) | 37 | + contenttype = request.GET['contenttype'] |
38 | + mapp = Maps.objects.get(id=int(maptype)) | ||
39 | + exportdatas = returnfarm_dbselect(contenttype, int(maptype)) | ||
40 | + except: | ||
41 | + mapp = Maps.objects.get(id=9) | ||
42 | + exportdatas = {} | ||
27 | context = {'exportdata': exportdatas, 'maps':mapp} | 43 | context = {'exportdata': exportdatas, 'maps':mapp} |
28 | return render(request, 'returnfarm.html', context) | 44 | return render(request, 'returnfarm.html', context) |
29 | 45 | ||
46 | + | ||
30 | def population(request): | 47 | def population(request): |
31 | - return render(request, 'population.html') | 48 | + try: |
49 | + maptype = request.GET['maptype'] | ||
50 | + densitytype = request.GET['densitytype'] | ||
51 | + mapp = Maps.objects.get(id=int(maptype)) | ||
52 | + exportdatas = publicdata() | ||
53 | + except: | ||
54 | + mapp = Maps.objects.get(id=9) | ||
55 | + exportdatas = {} | ||
56 | + exportdatas = publicdata() | ||
57 | + context = {'exportdata': exportdatas, 'maps':mapp} | ||
58 | + return render(request, 'population.html', context) | ||
32 | 59 | ||
33 | def market(request): | 60 | def market(request): |
34 | return render(request, 'market.html') | 61 | return render(request, 'market.html') |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
No preview for this file type
returnFarmvenv/Scripts/chardetect.exe
0 → 100644
No preview for this file type
returnFarmvenv/Scripts/f2py.exe
0 → 100644
No preview for this file type
면담확인서/면담확인서_전석희교수님_0526.hwp
0 → 100644
No preview for this file type
-
Please register or login to post a comment