This is a template for new Django projects that Thomas Welfley at Match Strike maintains.
See the requirements.txt file. These packages can be installed easily via PIP:
> pip install -r /path/to/requirements.txt
settings.py contains the default settings for all instances of your application. The settings listed in this file should be as cross platform compatible and complete as possible so that your app can work just about anywhere. However, if you intend to publish your software publicly, do not include passwords, keys, or other sensitive data in settings.py. Use placeholder values instead.
Use a local_settings.py file to override settings.py settings for specific instances. See the local_settings.py template for an example.
A context processor has been added that provides these nice variables to the default context: DEBUG, SITE_NAME, path, and domain.
django.contrib.admin and urls are enabled by default.
The structure is fairly straightforward. You'll want to tell your repository to ignore assets/css/site.r[0-9].css, assets/js/site.r[0-9].js, and assets/js/contrib/.
By default we include the jQuery form plugin, a Google Analytics plugin written by SquareFACTOR, and a script that automatically adds CSRF tokens to ajax requests. Note that we do not include jQuery itself. base.phtml instead links Google's non-minified jQuery.js file when in debug mode and Google's minified jQuery.js file when DEBUG==False.
When you deploy your application, you'll want to configure your web server to serve both of these files at the root of your application. Follow the links for a brief explanation of what they are:
We use .phtml instead of .html for our templates so that we can tell our text editors to use different syntax highlighting rules for django templates. If that bothers you, all you need to do is rename the files to *.html, change home.phtml in urls.py, an the you should be good to go.
base.phtml has markup in it that displays a warning message to users using IE 6 or below (see ie6 no more for additional information). If you intend to support IE 6, you'll need to remove that markup.
Aside from that, there isn't too much else to note. Be sure to read the comments in the templates (in particular, look at the big one at the end of base.phtml) and look to home.phtml for a nice example of using base.phtml to it's fullest.
- Export project_template to wherever you need it to be.
- In settings.py change:
- ADMINS
- SITE_NAME
- INSTALLED_APPS
- DEFAULT_FROM_EMAIL
- Tell your repository to ignore local_settings.py, assets/css/site.r[0-9].css, assets/js/site.r[0-9].js, and assets/js/contrib/
- By default, your app will generate a log called site.log when you use the logging library, and it will use site.css and site.js. I like to rename those to something that reflects the name of my application. For example, for a site where SITE_NAME="Match Strike", I'd rename those files to matchstrike.css, matchstrike.js, and matchstrike.log. If you'd like to do the same, rename site.css and site.js. Then change those file names in setting.py's COMPRESS_CSS and COMPRESS_JS vars. To change the name of the log file your site will create, change the filename property of the logging configuration in local_settings.py
- Replace img/favicon.ico with something more appropriate.
- Update the copyright information in base.phtml
- Develop!
Copyright (c) 2010-2011 Thomas Welfley. See LICENSE for details.