아래 내용보면 알지만 프로젝트 세팅과정이 엄청길다.. 따라하려면 해도 되지만 그냥 내가 만들어 둔것 쓰는 것도 답일 수 있음
- 프로젝트 생성 
- Pycharm -> Python 프로젝트 생성 -> 가상환경 세팅
 
 

- 장고 설치
 
$ pip install django
- 장고 설치 확인
 
$ django-admin

- 메인 프로젝트 설치
 
$ django-admin startproject coguri_main

- coguri_main에 가상환경 세팅 및 django 설치 
- coguri_main을 Pycharm에서 연다
 - File -> Settings -> Project coguri_main -> Python Interpreter
 
 

$ pip install django
- django 동작확인
 
$ python manage.py runserver

- 현재가 조회어플 생성
 
$ python manage.py startapp currentpriceapp

# coguri_main\settings.py
# ...
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'currentpriceapp',
]
# ...
- hello_world 출력
 
# currentpriceapp\views.py
# ...
def hello_world(request):
    return HttpResponse('Hello World')
# coguri_main\urls.py
# ...
urlpatterns = [
    path('admin/', admin.site.urls),
    path('currentprice/', include('currentpriceapp.urls')),
]
# ...
# currentpriceapp\urls.py
# ...
app_name = "currentpriceapp"
urlpatterns = [
    path('hello_world/', hello_world, name='currentprice')
]
- 동작확인
 
$ python manage.py runserver

- Git 세팅
 
VCS -> Enable Version Control Integration -> Git

SourceTree에서 보자면

- Git ignore 세팅
 
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn.  Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# 여기부터는 내가 세팅한 부분.
# 가상환경도 gitignore시킨다
venv/
# 환경파일도 gitignore
.env
# 여기는 그냥 받아들이자
db.sqlite3
.idea
__pycache__/
- 원격저장소 연결
 

원격저장소에 Push전 secretkey를 숨겨야 한다.
- SECRET_KEY 숨기기
 
# coguri_main\settings.py
# ...
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = # 여기있음.
# ...
$ pip install django-environ
.env파일 만들기
DEBUG=on
SECRET_KEY=[secrey-key를 넣자]
DATABASE_URL=psql://user:un-githubbedpassword@127.0.0.1:8458/database
SQLITE_URL=sqlite:///my-local-sqlite.db
CACHE_URL=memcache://127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213
REDIS_URL=rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=ungithubbed-secret
# coguri_main\settings.py
# ...
# .env 읽어오기
import environ
import os
env = environ.Env(
    # set casting, default value
    DEBUG=(bool, False)
)
# Set the project base directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Take environment variables from .env file
environ.Env.read_env(
    env_file=os.path.join(BASE_DIR, './.env')
)
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('SECRET_KEY')
# ...
# 빌드에러남. 아래와 같이 수정
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        # 'NAME': BASE_DIR / 'db.sqlite3',
        'NAME' : os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
- pip freeze
 
$ pip freeze > requirements.txt
- 여기까지 하고 push
 
