{"id":9576,"date":"2024-11-25T23:23:48","date_gmt":"2024-11-26T07:23:48","guid":{"rendered":"https:\/\/www.shop2world.com\/blog\/?p=9576"},"modified":"2024-11-27T22:54:01","modified_gmt":"2024-11-28T06:54:01","slug":"swsdjango-%ea%b0%9c%eb%b0%9c-%ec%84%9c%eb%b2%84-%ec%84%a4%ec%b9%98-%ec%84%b1%ea%b3%b5-%ea%b3%bc%ec%a0%95","status":"publish","type":"post","link":"https:\/\/www.shop2world.com\/blog\/archives\/9576","title":{"rendered":"\ud83d\ude80 [SWS] Django \uac1c\ubc1c \uc11c\ubc84 \uc124\uce58 \uac00\uc774\ub4dc \ud83c\udf1f"},"content":{"rendered":"\n<p>\uc774 \uac00\uc774\ub4dc\ub294 <strong>Shop2World<\/strong> \uc6f9\ud638\uc2a4\ud305 \uacc4\uc815\uc5d0\uc11c <strong>\uc11c\ube0c\ub3c4\uba54\uc778<\/strong>\uc5d0 Django \uac1c\ubc1c \uc11c\ubc84\ub97c \uc124\uce58\ud558\ub294 \ubc29\ubc95\uc744 \uc548\ub0b4\ud569\ub2c8\ub2e4. \ud83c\udf10<\/p>\n\n\n\n<ul><li><strong>\uc18c\uc694\uc2dc\uac04<\/strong>: \uc57d 5\ubd84 \u23f1\ufe0f<\/li><li><strong>\ud544\uc218 \uc870\uac74<\/strong>: \uc11c\ube0c\ub3c4\uba54\uc778 \uc0dd\uc131 \uc644\ub8cc \u2705<\/li><li><strong>\ub300\uc0c1<\/strong>: Shop2World \uc6f9\uc11c\ube44\uc2a4 \uc0ac\uc6a9\uc790 \ud83d\udc65<\/li><\/ul>\n\n\n\n<p>1\ufe0f\u20e3 Python 3.6 \uc124\uce58 \ud655\uc778 \ud83d\udc0d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3.6 -V  # Python 3.6.15<\/code><\/pre>\n\n\n\n<p>2\ufe0f\u20e3 \ud504\ub85c\uc81d\ud2b8 \ub514\ub809\ud1a0\ub9ac \uc0dd\uc131 \ubc0f \uc774\ub3d9 \ud83d\udcc2(\ub610\ub294 \uc0dd\uc131\ud55c \uc11c\ube0c\ub3c4\uba54\uc778 \ub514\ub809\ud1a0\ub9ac \uc774\ub3d9)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/var\/www\/vhosts\/shop2world.info\/python.shop2world.info<\/code><\/pre>\n\n\n\n<p>3\ufe0f\u20e3 \uac00\uc0c1\ud658\uacbd \uc0dd\uc131 \ubc0f \ud65c\uc131\ud654 \ud83c\udf1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3.6 -m virtualenv venv\nsource venv\/bin\/activate<\/code><\/pre>\n\n\n\n<p>\ud83d\udca1 <strong>\uac00\uc0c1\ud658\uacbd \ud65c\uc131\ud654 \ud655\uc778 \ubc29\ubc95<\/strong>:<\/p>\n\n\n\n<ul><li><code>(venv)<\/code> \ud45c\uc2dc\uac00 \ud504\ub86c\ud504\ud2b8 \uc55e\uc5d0 \ub098\ud0c0\ub098\uc57c \ud569\ub2c8\ub2e4.<\/li><li><code>python --version<\/code>\uc73c\ub85c \ubc84\uc804 \uc7ac\ud655\uc778 \ud83e\uddd0<\/li><\/ul>\n\n\n\n<p>4\ufe0f\u20e3 Django \ubc0f pysqlite3 \uc124\uce58 \ud83d\ude80<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install Django==2.2.28\npip install pysqlite3-binary<\/code><\/pre>\n\n\n\n<p>5\ufe0f\u20e3 Django \ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131 \ud83c\udfd7\ufe0f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>django-admin startproject config .<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>6\ufe0f\u20e3 <code>settings.py<\/code> \uc218\uc815 \ud83d\udee0\ufe0f (config\ud3f4\ub354\uc5d0 \uc788\uc74c)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import sys\nimport pysqlite3\nsys.modules&#91;'sqlite3'] = pysqlite3\nimport os\nos.environ.setdefault('PYTHONIOENCODING', 'utf-8')\nfrom pathlib import Path\n\n# Build paths inside the project like this: BASE_DIR \/ 'subdir'.\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = '\uc5ec\ub7ec\ubd84\uc758 \uc2dc\ud06c\ub9bf \ud0a4'\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = True\n\nALLOWED_HOSTS = &#91;'python.shop2world.info', 'www.python.shop2world.info', 'localhost', '127.0.0.1', '*'] #\uc790\uc2e0\uc758 \ub3c4\uba54\uc778\uc73c\ub85c \ubcc0\uacbd\n\n\n\n# Application definition\nINSTALLED_APPS = &#91;\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n]\n\nMIDDLEWARE = &#91;\n    'django.middleware.security.SecurityMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nROOT_URLCONF = 'config.urls'\n\nTEMPLATES = &#91;\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': &#91;],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': &#91;\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'config.wsgi.application'\n\n# Database\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',\n        'NAME': str(BASE_DIR \/ 'db.sqlite3'),\n    }\n}\n\n# Password validation\nAUTH_PASSWORD_VALIDATORS = &#91;\n    {\n        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\n    },\n]\n\n# Internationalization\nLANGUAGE_CODE = 'en-us'  # 'ko-kr'\uc5d0\uc11c 'en-us'\ub85c \ubcc0\uacbd\nTIME_ZONE = 'Asia\/Seoul'\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\n\n# Static files (CSS, JavaScript, Images)\nSTATIC_URL = '\/static\/'\nSTATIC_ROOT = str(BASE_DIR \/ 'static')\n\n# STATICFILES_DIRS \ucd94\uac00\nSTATICFILES_DIRS = &#91;\n    os.path.join(BASE_DIR, 'staticfiles'),\n]\n\n# Media files\nMEDIA_URL = '\/media\/'\nMEDIA_ROOT = str(BASE_DIR \/ 'media')\n\n# Default primary key field type\nDEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'\n\n# Security Settings (\uac1c\ubc1c \ubaa8\ub4dc\uc5d0\uc11c\ub294 \ube44\ud65c\uc131\ud654)\n# SECURE_SSL_REDIRECT = True\n# SESSION_COOKIE_SECURE = True\n# CSRF_COOKIE_SECURE = True<\/code><\/pre>\n\n\n\n<p>7\ufe0f\u20e3 \ud544\uc694\ud55c \ub514\ub809\ud1a0\ub9ac \uc0dd\uc131 \ud83d\udcc1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir static media staticfiles<\/code><\/pre>\n\n\n\n<p>8\ufe0f\u20e3 \uc815\uc801 \ud30c\uc77c \uc218\uc9d1 \ubc0f \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ub9c8\uc774\uadf8\ub808\uc774\uc158 \ud83d\udce6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python manage.py collectstatic\npython manage.py migrate<\/code><\/pre>\n\n\n\n<p>9\ufe0f\u20e3 \uac1c\ubc1c \uc11c\ubc84 \uc2e4\ud589 \ud83d\udd27<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python manage.py runserver 0.0.0.0:8000<\/code><\/pre>\n\n\n\n<p>\ud83c\udf10 \ube0c\ub77c\uc6b0\uc800\uc5d0\uc11c **<code>http:\/\/\uc12d\ub3c4\uba54\uc778:8000<\/code>**\uc73c\ub85c \uc811\uc18d\ud574 \ud655\uc778\ud558\uc138\uc694. \u2705<\/p>\n\n\n\n<h3>\ud83d\udd04 <strong>\ud3ec\ud2b8\ubc88\ud638 \uc8fc\uc758\uc0ac\ud56d<\/strong><\/h3>\n\n\n\n<p>\uc774\ubbf8 \ub2e4\ub978 \uc11c\ube0c\ub3c4\uba54\uc778\uc5d0\uc11c \uc2e4\ud589 \uc911\uc774\ub77c\uba74 \ud3ec\ud2b8\ub97c \ub2e4\ub974\uac8c \uc9c0\uc815\ud558\uc138\uc694:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python manage.py runserver 0.0.0.0:8001<\/code><\/pre>\n\n\n\n<p>\ud83d\udca1 <strong>\ud3ec\ud2b8 \uc0ac\uc6a9 \ud655\uc778<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps aux | grep runserver\n# \uc774\ubbf8 \uc0ac\uc6a9 \uc911\uc778 \ud3ec\ud2b8 \ud655\uc778 \uac00\ub2a5<\/code><\/pre>\n\n\n\n<h3>\ud83d\udee1\ufe0f \ubcf4\uc548 \uad00\ub828 \uc8fc\uc758\uc0ac\ud56d<\/h3>\n\n\n\n<ol><li>**<code>SECRET_KEY<\/code>**\ub294 \uc808\ub300 \uacf5\uac1c\ud558\uc9c0 \ub9c8\uc138\uc694! \ud83d\udd12<\/li><li>**<code>DEBUG = True<\/code>**\ub294 <strong>\uac1c\ubc1c \ud658\uacbd<\/strong>\uc5d0\uc11c\ub9cc \uc0ac\uc6a9\ud558\uc138\uc694. \u26a0\ufe0f<\/li><\/ol>\n\n\n\n<h3>1\ufe0f\u20e32\ufe0f\u20e3 \ub2e4\uc74c \ub2e8\uacc4<\/h3>\n\n\n\n<ul><li>\ud83d\udd11 <strong>\uad00\ub9ac\uc790 \uacc4\uc815 \uc0dd\uc131<\/strong>: <code>python manage.py createsuperuser<\/code><\/li><li>\ud83d\udee0\ufe0f <strong>\uc571 \uac1c\ubc1c \uc2dc\uc791<\/strong><\/li><li>\ud83d\ude80 <strong>\ud504\ub85c\ub355\uc158 \ubc30\ud3ec \uc900\ube44<\/strong><\/li><\/ul>\n\n\n\n<p>\ud83c\udf89 \uc774\uc81c Django \uac1c\ubc1c \uc11c\ubc84\uac00 \uc131\uacf5\uc801\uc73c\ub85c \uc124\uce58\ub418\uc5c8\uc2b5\ub2c8\ub2e4! \ud83d\ude4c<br><strong>\ucd94\uac00 \uc9c8\ubb38\uc774 \uc788\ub2e4\uba74 \uc5b8\uc81c\ub4e0\uc9c0 \ubb38\uc758\ud574\uc8fc\uc138\uc694. \ud83d\ude0a<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774 \uac00\uc774\ub4dc\ub294 Shop2World \uc6f9\ud638\uc2a4\ud305 \uacc4\uc815\uc5d0\uc11c \uc11c\ube0c\ub3c4\uba54\uc778\uc5d0 Django \uac1c\ubc1c \uc11c\ubc84\ub97c \uc124\uce58\ud558\ub294 \ubc29\ubc95\uc744 \uc548\ub0b4\ud569\ub2c8\ub2e4. \ud83c\udf10 \uc18c\uc694\uc2dc\uac04: \uc57d 5\ubd84 \u23f1\ufe0f \ud544\uc218 \uc870\uac74: \uc11c\ube0c\ub3c4\uba54\uc778 \uc0dd\uc131 \uc644\ub8cc \u2705 \ub300\uc0c1: Shop2World \uc6f9\uc11c\ube44\uc2a4 \uc0ac\uc6a9\uc790 \ud83d\udc65 1\ufe0f\u20e3 Python 3.6 \uc124\uce58 \ud655\uc778 \ud83d\udc0d 2\ufe0f\u20e3 \ud504\ub85c\uc81d\ud2b8 \ub514\ub809\ud1a0\ub9ac \uc0dd\uc131 \ubc0f \uc774\ub3d9 \ud83d\udcc2(\ub610\ub294 \uc0dd\uc131\ud55c \uc11c\ube0c\ub3c4\uba54\uc778 \ub514\ub809\ud1a0\ub9ac \uc774\ub3d9) 3\ufe0f\u20e3 \uac00\uc0c1\ud658\uacbd \uc0dd\uc131 \ubc0f \ud65c\uc131\ud654 \ud83c\udf1f \ud83d\udca1 \uac00\uc0c1\ud658\uacbd \ud65c\uc131\ud654 \ud655\uc778 \ubc29\ubc95: (venv) \ud45c\uc2dc\uac00 \ud504\ub86c\ud504\ud2b8 \uc55e\uc5d0 \ub098\ud0c0\ub098\uc57c \ud569\ub2c8\ub2e4. python &#8211;version\uc73c\ub85c \ubc84\uc804 \uc7ac\ud655\uc778 \ud83e\uddd0 4\ufe0f\u20e3 Django \ubc0f pysqlite3 \uc124\uce58 \ud83d\ude80 5\ufe0f\u20e3 Django &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[731],"tags":[733,734],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9576"}],"collection":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/comments?post=9576"}],"version-history":[{"count":10,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9576\/revisions"}],"predecessor-version":[{"id":9593,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9576\/revisions\/9593"}],"wp:attachment":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/media?parent=9576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/categories?post=9576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/tags?post=9576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}