티스토리 뷰

INTRO

Python 3.10.0

Django     3.2.8

 

 

# django 설정

BASE_DIR : ~/.pyenv/versions/3.10.0/envs/persona-erp/django-erp

 

- secret.json

django-erp 하위에 secret.json 파일 생성 후 setting.py의 SECRET_KEY 입력

{
	"SECRET_KEY": "[YOUR_KEY]"
}

 

- templates, statics, staticfiles

django-erp 하위에 폴더 3개 생성

.
├── config
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── manage.py
├── secret.json
├── staticfiles
├── statics
└── templates

 

 

- django-erp/config/settings.py 설정

from pathlib import Path
import os, json
from pytz import common_timezones
from django.core.exceptions import ImproperlyConfigured

....

BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')

....


# SECURITY WARNING: keep the secret key used in production secret!
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")

....


INSTALLED_APPS = [
    'django.contrib.humanize',
	....
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
                TEMPLATES_DIR,
        ],
       ....
]

....

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'ko'

TIME_ZONES = [(tz, tz) for tz in common_timezones]
TIME_ZONE = 'GMT'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
                    os.path.join(BASE_DIR, 'statics'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_REDIRECT_URL = '/home'
LOGOUT_REDIRECT_URL = '/'

(persona-erp)$ ./manage.py runserver

browser 실행 : http://localhost:8000/

 

# superuser 등록

(persona-erp)$ ./manage.py migrate

(persona-erp)$ ./manage.py createsuperuser

사용자 이름 : 

이메일 주소: 
Password:
Password (again):

 

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함