본문 바로가기

Django Deployment 본문

개발/Django

Django Deployment

Louisus 2020. 5. 13. 11:49
728x90

- ORMs, Advanced User Authorization, Social Login, Payments, REST APIs, Encryption, Testing, Sessions, Cookies, Class-Based Views, etc…

- There are many options for deploying your site –

Each option comes with trade-offs – price/scalability/security/ease of use / etc

 

# www.pythonanywhere.com

# bash console

 

mkvirtualenv --python=python3.7.6 myproj

 

pip install -U django==3.0.3

 

----------------

# Your own terminal

python

>> import django

>> django.__version__

'3.0.3' # Your django version

----------------

 

which django-admin.py

/home/dobi1115/.virtualenvs/myproj/bin/django-admin.py

 

git clone https://github.com/louisuss/django-deployment-example.git

 

python manage.py migrate

python manage.py makemigrations basic_app

python manage.py migrate

 

python manage.py createsuperuser

 

# Web -> Django -> Manual Configuration

 

# Setting up the virtualenv on the web

/home/dobi1115 (username)/.virtualenvs/myproj (virtualenv name)

 

# Add source code path on the web

/home/dobi1115/django-deployment-example/learning_templates

 

# Editing WSGI configuration file

 

# +++++++++++ DJANGO +++++++++++

# To use your own django app use code like this:

import os

import sys

#

## assuming your django settings file is at '/home/dobi1115/mysite/mysite/settings.py'

## and your manage.py is is at '/home/dobi1115/mysite/manage.py'

path = '/home/dobi1115/django-deployment-example/learning_templates'

if path not in sys.path:

    sys.path.append(path)

os.chdir(path)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'learning_templates.settings')

 

import django

django.setup()

#

#os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

#

## then:

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

 

# Editing settings.py -> ALLOWED_HOSTS

 

ALLOWED_HOSTS = ['HOST']

 

# static file URL / Directory

/static/admin

/home/dobi1115(username)/.virtualenvs/myproj/lib/python3.5/site-packages/django/contrib/admin/static/admin

 

/static/

/home/dobi1115(username)/django-deployment-example/learning_templates/static

 

# Editing settings.py

DEBUG = False

 

'개발 > Django' 카테고리의 다른 글

CBV (Class Based Views)  (0) 2020.05.13
Login / Logout pages Implementation  (0) 2020.05.09
Templates - Relative URLs+ Inheritance + Filter  (0) 2020.05.07
장고 공부법  (0) 2020.05.07
Data List on the web page  (0) 2020.05.05
Comments