A modern Django (1.4) project skeleton.
- author: Randall Degges
- email: rdegges@gmail.com
- status: maintained, in development
- notes: Have feedback? Please send me an email. This project is still in its infancy, and will be changing rapidly.
For background, see: http://rdegges.com/deploying-django
Essentially--deploying Django projects is hard. There are lots of things you need to take into consideration. Being a Django user for years, I believe I've found some extremely useful patterns to help manage all sorts of Django sites (from the very smallest apps, to the largest).
This project is meant to be a boilerplate project for starting development. It is heavily opinionated in terms of services and tools--but I think the tradeoff is worthwhile.
The full project documentation is hosted at RTFD: http://django-skel.rtfd.org/. They are continuously updated to reflect changes and information about the project, so be sure to read them before using this boilerplate.
django-skel currently supports Django 1.4. To create a new django-skel base project, run the following command (this assumes you have Django 1.4 installed already):
$ django-admin.py startproject --template=https://github.com/rdegges/django-skel/zipball/master woot
$ heroku config:add DJANGO_SETTINGS_MODULE=myproject.settings.prod
Where woot
is the name of the project you'd like to create.
This is possible because Django 1.4's startproject
command allows you to
fetch a project template over HTTP (which is what we're doing here).
While not strictly required, it is also recommended to do
$ heroku config:add SECRET_KEY=putsomethingfairlycomplexhere
The production settings pull SECRET_KEY from environment but fallbacks to a value which is generated mainly for development environment.
This setup allows you to easily keep your site in a public repo if you so wish without causing opening a route to attack your Django passwords.
- SET UP DATABASE Create a user account and database
sudo -u postgres createuser [username] sudo -u postgres createdb [dbname]
Set up a password
sudo -u postgres psql ALTER USER [username] with encrypted password 'your_password';
-
CREATE A PROJECT django-admin.py startproject --template=https://github.com/harry81/django-skel/zipball/master [project name]
-
CONFIGURE IT UP FOR DJANGO vi [project name]/settings/common.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'map', 'USER': 'map', 'PASSWORD': 'jkl', 'HOST': '', 'PORT': '',
} } -
ADD YOUR APP THIRD_PARTY_APPS LOCAL_APPS = ( 'apps.[project name]', )
-
PREPARE ALL TABLES python manage.py syncdb
-
START DJANGO DEVELOPMENT SERVER python manage.py runserver -> See using your browser if a web server works well.
-
CREATE YOUR OWN APP cd [project name] django-admin.py startapp --template=https://github.com/harry81/django-skel-app/zipball/master [project name] mv [project name]/* apps rm -rf [project name]