Skip to content

Instantly share code, notes, and snippets.

@terryoy
Created December 8, 2012 16:21
Show Gist options
  • Save terryoy/4240884 to your computer and use it in GitHub Desktop.
Save terryoy/4240884 to your computer and use it in GitHub Desktop.
sae django setup
# install virtualenv to manage the environment
sudo apt-get install python-virtualenv
# create site folder
mkdir mysite
cd mysite
# activatet the virtualenv environment
virtualenv venv
source venv/bin/activate
# install mysql-python, it must be prior to django installation
# (apt-get is optional if you already installed the packages)
sudo apt-get build-dep python-mysqldb
pip install MySQL-python
# install django and create new project
pip install Django==1.4
django-admin.py startproject myproject
cd myproject
vi config.yaml
# (config.yaml content:)
# name: myproject
# version: 1
# libraries:
# - name: "django"
# version: "1.4"
vi index.wsgi
# (index.wsgi content:)
# import sae
# from enurse import wsgi
#
# application = sae.create_wsgi_app(wsgi.application)
ls
# (ls result should have: config.yaml <myproject> index.wsgi manage.py)
# check out the dev server environment of SAE
git clone http://github.com/SAEPython/saepythondevguide.git
# setup dev server
cd saepythondevguide/dev_server
python setup.py install
# start django project without database
dev_server.py
# update database in settings.py
cd myproject
vi settings.py
# (MySQL configuration:)
# import sae.const
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
# 'NAME': sae.const.MYSQL_DB, # Or path to database file if using sqlite3.
# 'USER': sae.const.MYSQL_USER, # Not used with sqlite3.
# 'PASSWORD': sae.const.MYSQL_PASS, # Not used with sqlite3.
# 'HOST': sae.const.MYSQL_HOST, # Set to empty string for localhost. Not used with sqlite3.
# 'PORT': sae.const.MYSQL_PORT, # Set to empty string for default. Not used with sqlite3.
# }
# }
# start dev server with MySQL database
dev_server.py --mysql=user:password@localhost:3307
# voila! you should be able to see the hello page on http://localhost:8080/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment