티스토리 뷰

1. django SECRET_KEY 보안설정

(pyERP)testerp$ nano config/settings.py

....

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '[YourKey]'

....

 

(pyERP)testerp$ nano secret.json

(pyERP)testerp$ touch secret.json

(pyERP)$ pip install django

{
    "SECRET_KEY": "[YourKey]"
}

(pyERP)testerp$ nano config/settings.py

import os, json
from django.core.exceptions import ImproperlyConfigured
....

secret_file = os.path.join(BASE_DIR,'secret.json')
with open(secret_file) as f:
     secret = json.loads(f.read())

def get_secret(setting, secret=secret):
    try:
        return secret[setting]
    except KeyError:
    	raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_secret("SECRET_KEY")
....

(pyERP)testerp$ ./manage.py runserver

browser localhost:8000 확인

 

2. git push/pull

(pyERP)testerp$ nano .gitignore

secret.json 추가

.DS_Store
db.sqlite3
*.pyc
__pycache__/ 
secret.json

 

git push

[macOS](pyERP)testerp$ git init

[macOS](pyERP)pyERP git:(master)$ git add .

[macOS](pyERP)pyERP git:(master)$ git commit -m "testerp 2nd commit : secret key"

[macOS](pyERP)pyERP git:(master)$ git remote add origin https://github.com/YourRepoName.git

[macOS](pyERP)pyERP git:(master)$ git push -f origin master

 

 

git pull/fetch

[Raspi](pyERP)testerp$ git init

[Raspi](pyERP)pyERP git:(master)$ git remote add origin https://github.com/YourRepoName.git

[Raspi](pyERP)testerp$ git pull

[Raspi](pyERP)testerp$ git status

[Raspi](pyERP)testerp$ git fetch --all

Fetching origin

Username for 'https://github.com': [YourGitHubID]

Password for 'https://[YourID]@github.com': [YourGitHubPass]

[Raspi](pyERP)testerp$ git reset --hard origin/master

[Raspi](pyERP)testerp$ git status

 

SECRET_KEY 적용

[Raspi](pyERP)testerp$ touch secret.json

[Raspi](pyERP)testerp$ nano secret.json

{
    "SECRET_KEY": "[YourKey]"
}

[Raspi](pyERP)testerp$ nano config/settings.py

#ALLOWED_HOSTS = ['localhost']
ALLOWED_HOSTS = ['[RaspiIP]']

[Raspi](pyERP)testerp$ uwsgi --ini testerp.ini

server django 구동 확인

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함