양선아

5/29 update

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://127.0.0.1:8000/market_analysis/returnfarm?maptype=9&contenttype=edu",
"webRoot": "${workspaceFolder}"
}
]
}
\ No newline at end of file
......@@ -11,23 +11,33 @@
</head>
<body>
<h1><a href="http://127.0.0.1:8000/market_analysis/maplist">Statistics on Return Farm Project</a></h1>
<br>
<h3>농산물 시장 유통에 대한 통계분석 입니다.</h3>
<br>
<ul class="nav justify-content-center">
<!--body-->
<div id="bodyWrap">
<div id="header">
<h1><a href="/market_analysis/maplist">Statistics on Return Farm Project</a></h1>
<br>
<h3>농산물 시장 유통에 대한 통계분석 입니다.</h3>
<br>
</div>
<div id="menubar">
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" href="http://127.0.0.1:8000/market_analysis/market">Market</a>
<a class="nav-link active" href="/market_analysis/market">Market</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://127.0.0.1:8000/market_analysis/population">Population</a>
<a class="nav-link" href="/market_analysis/population">Population</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://127.0.0.1:8000/market_analysis/returnfarm">Return Farm</a>
<a class="nav-link" href="/market_analysis/returnfarm">Return Farm</a>
</li>
</ul>
</div>
</div>
<!--content-->
<div id="contentWrap">
<h6>
explain 들어가는 부분
</h6>
</div>
</body>
</html>
\ No newline at end of file
......
from django.conf.urls import url
from django.urls import path
from . import views
urlpatterns = [
url('returnfarm/<int:maptype>', views.returnfarm),
url('population', views.population),
url('returnfarm', views.returnfarm, name="returnfarm"),
url('population', views.population, name="population"),
url('market', views.market),
url('', views.main),
]
\ No newline at end of file
......
#-*- coding:utf-8
from django.shortcuts import render
from django.db.models import Count
from django.db.models import Count, Max
from urllib.request import urlopen
from .models import RT_edu, Maps, RT_agri_policy
from bs4 import BeautifulSoup
import pandas as pd
# Create your views here.
def dbselect(contenttype, maptype):
def returnfarm_dbselect(contenttype, maptype):
if maptype == 9:
mapt = 'city'
elif maptype == 10:
mapt = 'cntr'
if contenttype=='policy':
myrtrn = RT_agri_policy.objects.values(mapt).annotate(count=Count(mapt))
return myrtrn
......@@ -17,18 +21,41 @@ def dbselect(contenttype, maptype):
myrtrn = RT_edu.objects.values(mapt).annotate(count=Count(mapt))
return myrtrn
# 공공데이터 불러오는 부분
def publicdata():
# 통계청 귀농가구원의 시도별, 시군별, 연령별
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'
data = urlopen(url).read().decode('utf8')
return data
def main(request):
return render(request, 'main.html')
def returnfarm(request, maptype):
mapp = Maps.objects.get(id=maptype)
mapp = mapp.mapdata
exportdatas = dbselect('policy', maptype)
def returnfarm(request):
try:
maptype = request.GET['maptype']
contenttype = request.GET['contenttype']
mapp = Maps.objects.get(id=int(maptype))
exportdatas = returnfarm_dbselect(contenttype, int(maptype))
except:
mapp = Maps.objects.get(id=9)
exportdatas = {}
context = {'exportdata': exportdatas, 'maps':mapp}
return render(request, 'returnfarm.html', context)
def population(request):
return render(request, 'population.html')
try:
maptype = request.GET['maptype']
densitytype = request.GET['densitytype']
mapp = Maps.objects.get(id=int(maptype))
exportdatas = publicdata()
except:
mapp = Maps.objects.get(id=9)
exportdatas = {}
exportdatas = publicdata()
context = {'exportdata': exportdatas, 'maps':mapp}
return render(request, 'population.html', context)
def market(request):
return render(request, 'market.html')
\ No newline at end of file
......
No preview for this file type
No preview for this file type
No preview for this file type