Skip to content

Instantly share code, notes, and snippets.

@durden
Created June 16, 2011 02:27
Show Gist options
  • Save durden/1028560 to your computer and use it in GitHub Desktop.
Save durden/1028560 to your computer and use it in GitHub Desktop.
Deployment of Django 1.2 app to Gondor (http://gondor.io)
** Structure should have repo directory then django project directory under it.
** Only files that are committed to the repo are used in deployment.
** Make sure to not have any other .git projects/directories in your project
other than the one at the top level. This causes problems like not finding
settings files, etc.
** <project> refers to the 'main' project where your git repository (.git
directory resides)
** <project_name> refers to the 'main' django project directory (were
settings.py resides)
- mkdir <project>
- cd <project>
- git init .
- django-admin startproject <project_name>
- Create virtualenv for project
- mkdir ~/.virtualenvs
- virtualenv --no-site-packages -v -p <python_path> ~/.virtualenvs/<project>
- Python path for OSX: /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
- This installs pip into THIS virtualenv.
- Activate/switch to using virtualenv
- work_on <project>
- Create requirements file with at least the following:
django==1.2.1
gondor==1.0b1.post7
psycopg2==2.4.1
- Make sure to include django-staticfiles if you need it on Django 1.2
- Use requirements file to install all project libraries:
- pip install -E ~/.virtualenvs/<project>/ -v -r <requirements_file>
- Write code
- Commit code
- Create site via gondor.io interface
- cd <project_name>
- gondor init <site_key>
- Create <project_name>/deploy/
- touch __init__.py
- Create deploy/wsgi.py with at least the following:
import os
import sys
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
os.pardir, os.pardir)))
sys.path.insert(0,
os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
os.pardir)))
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = '<project_name>.settings'
application = WSGIHandler()
- edit <project_name>/.gondor/config
- Make sure to path to requirements file is correct
- Set staticfiles to 'on' if you are serving static files with the
django-staticfiles project
- (don't worry about this if your on Django 1.3+)
- Configure django-staticfiles (if using Django 1.3)
- Add 'staticfiles' to INSTALLED_APPS
- Add the following variables in settings.py
- STATIC_ROOT = os.path.join(os.path.dirname(__file__), 'media/')
- Location on your local hard drive
- STATIC_URL = '/static/'
- URL all your templates use
- Add following to top of manage.py
import os
import sys
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
os.pardir, os.pardir)))
sys.path.insert(0,
os.path.abspath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
os.pardir)))
- Add following to bottom of settings.py
try:
from local_settings import *
except ImportError:
pass
** Commit all changes to your repository
- cd <project_name>
- gondor deploy primary master
** Extras **
- Create super user for Django admin
- gondor run primary createsuperuser
- Upload existing JSON data
- gondor run primary loaddata <json_file>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment