- setup the environment below
- install dependencies
- setup db refer to postgres-kimchi-reference
- python manage.py runscripts generate-secret-key
- setup the SECRET_KEY environment
- run 3 data scripts eg. python manage.py runscripts insert-whatever-data
- python3 manage.py runserver 8000
preq: setup the model mentioned above location: test_Model.py python3 manage.py test
- comment out app from settings.py
- since django 1.8 AppConfig is required and configured to app.apps.WorldCupWatsonConfig in INSTALLED_APP and init.py in app folder
- python manage.py buildwatson
- index should have been updated
- http://django-template-debug.readthedocs.org/en/latest/_templates/set_trace.html
- place this on html for debugging
{% load debug_tags %}
- eg. render to simulate the template rendering and available command such as details and variables
render('{% if item.magical %}A magical item {% endif %}')
- caveat: iterable object have to be passed to html and eg of direct accessing list using VardotIndex
- brew install pyenv
- add below to .bash_profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
- brew install pyvenv
- pyenv install 3.4.3 (or any version)
- go to project directory and pyvenv my-env
- source my-env/bin/activate
- python or python3 --version should point to 3.4.3
- pip install -U pip
- sudo apt-get install virtualenv
- virtualenv my-env -p /usr/bin/python3
- source my-env/bin/activate
- python --version
- pip install -U pip
- gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application
- sudo vim /etc/init/gunicorn.conf
description "Gunicorn application server handling myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid user
setgid www-data
chdir /home/user/myproject
exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/user/myproject/myproject.sock myproject.wsgi:application
- sudo service gunicorn start
- sudo vim /etc/nginx/sites-available/myproject
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/user/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/user/myproject/myproject.sock;
}
}
- sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
- sudo nginx -t # Test Nginx configuration for syntax errors
- sudo service nginx restart
- Setup everything and please do not use root user
* python manage.py collectstatic
* gunicorn worldcup.wsgi:application --bind=127.0.0.1:8001 --daemon
- nginx setup like below on eg /etc/nginx/sites-enabled/worldcup
server {
listen 80;
server_name server_ip_or_address_domain;
location / {
proxy_pass http://127.0.0.1:8001;
}
location /static/ {
alias /home/whateverUser...../swe-worldcup/src/worldcup/staticfiles/;
}
}
- Python 3.4+
- Django 1.8.7
- Postgres 9.4
- PyJade 3.1
- Twitter Bootstrap
- jQuery
- Gunicorn
- Nginx
- and more ...
- Kim Yu Ng