양선아

web project

"""
ASGI config for ReturnFarm project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ReturnFarm.settings')
application = get_asgi_application()
"""
Django settings for ReturnFarm project.
Generated by 'django-admin startproject' using Django 3.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'ph*v6_rhrfblbgme=rb@5(!jpp0i043p&q9km#)8acj$0*v08f'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'market_analysis',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ReturnFarm.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'ReturnFarm.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mrkt_analysis',
'USER': 'mrktanaly',
'PASSWORD' : 'mrktanaly',
'HOST' : 'localhost',
'PORT' : '5433',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
\ No newline at end of file
"""ReturnFarm URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('admin/', admin.site.urls),
path('market_analysis/', include('market_analysis.urls')),
]
"""
WSGI config for ReturnFarm project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ReturnFarm.settings')
application = get_wsgi_application()
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ReturnFarm.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
from django.contrib import admin
from .models import RT_edu
# Register your models here.
admin.site.register(RT_edu)
from django.apps import AppConfig
class MarketAnalysisConfig(AppConfig):
name = 'market_analysis'
# Generated by Django 3.0.6 on 2020-05-18 03:21
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='RT_edu',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('city', models.CharField(max_length=5)),
('cntr', models.CharField(max_length=10)),
('edu_name', models.CharField(max_length=50)),
('edu_center', models.CharField(max_length=30)),
('edu_start', models.DateField()),
('edu_end', models.DateField()),
('edu_time', models.IntegerField()),
('edu_infocall', models.CharField(max_length=15)),
],
),
]
# Generated by Django 3.0.6 on 2020-05-18 04:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('market_analysis', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='rt_edu',
name='edu_infocall',
field=models.CharField(max_length=30),
),
]
# Generated by Django 3.0.6 on 2020-05-18 04:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('market_analysis', '0002_auto_20200518_1331'),
]
operations = [
migrations.AlterField(
model_name='rt_edu',
name='city',
field=models.CharField(max_length=7),
),
migrations.AlterField(
model_name='rt_edu',
name='cntr',
field=models.CharField(max_length=7),
),
]
from django.db import models
# Create your models here.
class RT_edu(models.Model):
city = models.CharField(max_length=7)
cntr = models.CharField(max_length=7)
edu_name = models.CharField(max_length=50)
edu_center = models.CharField(max_length=30)
edu_start = models.DateField()
edu_end = models.DateField()
edu_time = models.IntegerField()
edu_infocall = models.CharField(max_length=30)
#mapid{height: 180px;}
\ No newline at end of file
<html>
<head>
<!-- link에 들어가 있는건 지도 데이터를 위한 css 파일 -->
<!-- script에 들어가 있는건 지도 데이터를 위한 js 파일 -->
<!-- 직접 다운받아 넣을 수도 있는데 우선은 그냥 웹에서 불러올 수 있도록 해놨다. -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script>
<!--css 내용 여기에 direct로 넣었다-->
<style>
#map {top:100; bottom:100; left:10; right:10; }
</style>
</head>
<body>
{% for cont in educations %}
<p>where : {{cont.city}}</p>
<p>where : {{cont.ct}}</p>
{% endfor %}
<div id="map"></div>
<script>
// map 객체 생성
// 위도, 경도, zoom 수준
var map = L.map('map').setView([0,0],3);
// tilelayer를 씌우는 작업 OSM을 사용했음
L.tileLayer('https://api.maptiler.com/maps/positron/{z}/{x}/{y}.png?key=IHLiEj11tKzE3WCyeanP',{
attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>',
}).addTo(map)
</script>
</body>
</html>
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from . import views
urlpatterns = [
url('test', views.test),
]
\ No newline at end of file
from django.shortcuts import render
from django.db.models import Count
from .models import RT_edu
# Create your views here.
def test(request):
educations = RT_edu.objects.values('city').annotate(ct=Count('city'))
context = {'educations': educations}
return render(request, 'test.html', context)
\ No newline at end of file