Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heroku배포 중 #33

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
release: python manage.py migrate
release: python manage.py migrate
web: gunicorn config.wsgi:application
Empty file added config/settings/__init__.py
Empty file.
287 changes: 140 additions & 147 deletions config/settings.py → config/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,147 +1,140 @@
"""
Django settings for config project.

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

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/
"""
import os
from pathlib import Path

# 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 = 'django-insecure-zyk%w)7ii+ubn09fq+gd_cx8qj7+zjvs8+mqeu)^rvx-_w_yc*'

# 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',
'django.contrib.sites',
'django.contrib.humanize',

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.kakao',
'allauth.socialaccount.providers.naver',
'allauth.socialaccount.providers.google',

'main',
]

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',

'allauth.account.auth_backends.AuthenticationBackend',
)

SITE_ID = 2

SOCIALACCOUNT_AUTO_SIGNUP = True

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 = 'config.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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 = 'config.wsgi.application'

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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'mydatabase',
}
}

# 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 = 'ko-KR'

TIME_ZONE = 'Asia/Seoul'

USE_I18N = True

USE_TZ = True

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

STATIC_URL = '/static/' # static파일에 직접 접근하기 위한 경로
STATICFILES_DIRS = [
BASE_DIR / 'static',
]

MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # media가 저장되는 경로
MEDIA_URL = '/media/' # url에서 media의 각 파일에 직접 접근하기 위한 경로(media/video.mv4)

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'main.User'
LOGIN_REDIRECT_URL = '/account/signup/'
LOGOUT_REDIRECT_URL = '/diary_show/'
"""
Django settings for config project.

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

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/
"""
import os
from pathlib import Path

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

# 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 = 'django-insecure-zyk%w)7ii+ubn09fq+gd_cx8qj7+zjvs8+mqeu)^rvx-_w_yc*'

# 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',
'django.contrib.sites',
'django.contrib.humanize',

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.kakao',
'allauth.socialaccount.providers.naver',
'allauth.socialaccount.providers.google',

'main',
]

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',

'allauth.account.auth_backends.AuthenticationBackend',
)

SITE_ID = 2

SOCIALACCOUNT_AUTO_SIGNUP = True

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 = 'config.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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 = 'config.wsgi.application'

# 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 = 'ko-KR'

TIME_ZONE = 'Asia/Seoul'

USE_I18N = True

USE_TZ = True

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

STATIC_URL = '/static/' # static파일에 직접 접근하기 위한 경로
STATICFILES_DIRS = [
BASE_DIR / 'static',
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')


MEDIA_ROOT = os.path.join(BASE_DIR, '../../media') # media가 저장되는 경로
MEDIA_URL = '/media/' # url에서 media의 각 파일에 직접 접근하기 위한 경로(media/video.mv4)

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'main.User'
LOGIN_REDIRECT_URL = '/account/signup/'
LOGOUT_REDIRECT_URL = '/diary_show/'
22 changes: 22 additions & 0 deletions config/settings/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .base import *
import django_heroku

DEBUG = False

ALLOWED_HOSTS = ['*']

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

django_heroku.settings(locals())

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'd30il9ibgijs4l',
'USER': 'irxukxprszsmwj',
'PASSWORD': 'bfb2fde7829666175e47e3c387287b6d58329375391dbf7be8cc599a3e01c572',
'HOST': 'ec2-34-198-186-145.compute-1.amazonaws.com',
'PORT': '5432',
}
}
12 changes: 12 additions & 0 deletions config/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .base import *

DEBUG = True

ALLOWED_HOSTS = ['*']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'mydatabase',
}
}
2 changes: 1 addition & 1 deletion config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.deploy')

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Diary(models.Model):
diary_img = models.ImageField(upload_to='diary_img/', null=True, blank=True, default='default_img/paper.jpg')
diary_share_state = models.BooleanField(default=False)
diary_share_date = models.DateTimeField(auto_now_add=True)
like_user = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='like_diary')
like_user = models.ManyToManyField(settings.base.AUTH_USER_MODEL, related_name='like_diary')


class Board(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down