This presentation covers deploying Django in production server. The topics that are mainly covered includes
O Environment setup
O Server configuration
O Deploying in AWS
5. Environment setup > pip
Its a tool for installing Python packages from PyPI.
Install: sudo apt-get install python-pip
Example:
$ pip install PackageName # latest version
$ pip install PackageName ==1.0.4 # specific version
$ pip install PackageName >=1.0.4' # minimum version
$ pip uninstall PackageName
Presenter: Premananda Das, Mindfire Solutions
6. Environment setup > Virtualenv
Presenter: Premananda Das, Mindfire Solutions
A tool to create isolated Python environments.
$ pip install virtualenv
Example:
Create Environment: $ virtualenv venv
Activate Environment: $ source venv/bin/activate
Install Packages: $ pip install requests
Deactivate Environment: $ deactivate
Virtualenvwrapper is a set of extensions to virtualenv tool. It
provides commands to make it easy to work with virtualenv.
Create virtual environment: mkvirtualenv mynewenv
List virtual environment: lsvirtualenv
Remove a virtual environment: rmvirtualenv myenv
7. Environment setup > Django
Presenter: Premananda Das, Mindfire Solutions
Install: $ pip install django
New project: $ django-admin.py startproject myproject
1. Keep the app name concise - simple and one word.
2. Use flake8 to check coding convention - PEP8.
3. django-dotenv - avoid using local_settings.py.
4. Error handling and logging: logger - error and exception with log rotate.
5. DEBUG = False.
6. DB log error and analyse slow queries.
7. django-debug-toolbar for debugging.
8. Don’t reinvent the wheel.
9. Environment setup > git
Presenter: Premananda Das, Mindfire Solutions
Ubuntu: sudo apt-get install git
1. Working directory must be kept clean.
2. All files should be committed to git.
3. Server configs can be kept in git.
4. Don’t keep any application and database password in git.
5. Follow process: Gitflow Workflow
20. Tools
Presenter: Premananda Das, Mindfire Solutions
1. New Relic: Server and application monitoring
2. Sentry: Gives insight into the application errors
3. Jenkins for CI, unittest
4. Fabric: Application deployment or system administration tasks
over SSH.