[Terarosa] Initial setting

do yeon kim·2022년 7월 31일
0

Project_Terarosa 회고

목록 보기
2/7

Initial Setting

회고록

프로젝트는 혼자서 진행되는 것이 아니다 보니, 다른 백엔드 개발자와 초기세팅을 맞출 필요가 있다.
어떠한 스텍을 사용할지, 사용할 스텍은 어떤 버전을 사용할지 등을 맞추어야 협업이 가능하다. 그렇지 않으면 한쪽에서는 문제없이 돌아가지만, 다른 한쪽에서는 문제가 발생할 수 있다.

다른 과제를 하면서 여러번 초기 세팅을 해 보았지만, 할 때마다 헷갈리는 이유는 무었일까.....

git ignore를 잘못해서, 올라가지 말아야 할 파일들 까지 올라가버렸다.

왜 혼자서 할때는 잘되는게 다른사람과 같이 할려면 문제가 생기는지 알수가 없다.

다행히 git 원격저장소에 잘못 올라간 파일을 삭제하는 방법이 있어서 잘마무리가 되었지만, 초기부터 피해를 끼치는 생각이 든다.



github에 잘못올라간 파일 삭제하기

// 원격 저장소와 로컬 저장소에 있는 파일을 삭제한다.
$ git rm [File Name]

// 원격 저장소에 있는 파일을 삭제한다. 로컬 저장소에 있는 파일은 삭제하지 않는다.
$ git rm --cached [File Name]

참고
https://gmlwjd9405.github.io/2018/05/17/git-delete-incorrect-files.html



전체적인 초기 세팅

가상환경 생성

# 가상환경 생성
conda create -n terarosa python=3.8
conda activate terarosa

데이터베이스 생성

$ mysql -u root -p

mysql> create database terarosa character set utf8mb4 collate utf8mb4_general_ci;

파이썬 패키지 설치

$ pip install django

# 이후에 MySQL server에 접속하기 위한 package
$ pip install mysqlclient
(중요) mysql 설치되어 있는지 먼저 확인해주세요

장고 프로젝트 시작

django-admin startproject terarosa

settigs.py 설정

"""
Django settings for terarosa project.

Generated by 'django-admin startproject' using Django 4.0.6.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

from pathlib     import Path
from my_settings import DATABASES, SECRET_KEY, ALGORITHM

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = SECRET_KEY

ALGORITHM  = ALGORITHM

# 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',
    'corsheaders',
    'users',
    'products',
    'orders',
    'carts',
    'core',
]

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',
    'corsheaders.middleware.CorsMiddleware',

]

ROOT_URLCONF = 'terarosa.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 = 'terarosa.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = DATABASES

# Password validation
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


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

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

##CORS
CORS_ORIGIN_ALLOW_ALL=True
CORS_ALLOW_CREDENTIALS = True

CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
)

CORS_ALLOW_HEADERS = (
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
)

APPEND_SLASH = False

my_settings.py

DATABASES = {
    'default' : {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

SECRET_KEY = 

ALGORITHM  = 

gitignore 생성

touch .gitignore
vi .gitignore

0개의 댓글