Django Project Template is a collection of development tasks and optimizations aimed at anyone doing news application development on tight deadlines in Django. Highlights include:
lib
directory with some of our favorite code snippets and custom Django mangement commandsThis project supports Ubuntu Linux 14.04 and Mac OS X Yosemite. It is not tested or supported for the Windows OS.
$ mkvirtualenv project_name
$ pip install django fabric
$ django-admin.py startproject --extension=py,.gitignore --template=https://github.com/cirlabs/django-project-template/archive/master.zip project_name
$ cd project_name
$ fab bootstrap # bootstrap project
While this template works fine out the box, it's recommended you use use our yeoman generator to manage your static assets (HTML, CSS, JS). We built generator-newsapp to work in concert with this project template. For this to work you'll need Node.js 0.12.x or io.js 1.2.x.
After running the quick start above run fab scaffold
to install the required node.js libraries and generate the templates needed for frontend development.
Note: If you already have the npm modules installed, you can skip installing them by running fab scaffold:skip-install
.
This project assumes you have an Amazon S3 bucket where you host your apps. They are static apps with no database calls.
Update settings/production.py
with the various s3 buckets you'll use. We have buckets for staging (testing the application), buckets for media assets and a final bucket publishing. You can use these conventions or change them. You'll also need to add the Django Bakery views you want generated.
You'll also need to create a settings/local_settings.py
file with your AWS secret key and ID. By default this file will not be checked into version control. Keep it that way just in case your open source your project. This ensures you keys won't leak out to the world.
With those files configured, run fab deploy
to publish your application to the world.
You can certainly use this template for dynamic applications that use a live server and a database, but currently there is no deployment chain pre-configured at this time.
By default, this project assumes you'll be using PostGIS as your database. If you'd prefer not to, you can set the USE_POSTGIS
variable in settings/common.py
to False
and the project will default to PostgreSQL. :warning: Be sure to do this BEFORE running the quickstart.
Here are the various fabric tasks included in the project. See fabfile.org to learn more about Fabric and Python task execution.
bootstrap DEFAULT: Run commands to setup a new project
bower usage: fab bower:<command>, <args>, <option>
clear Remove a model from an application database
compress shortcut for django compressor offline compression command
createdb Creates local database for project
deploy_to_s3 Deploy project to S3.
destroy destoys the database and django project. Be careful!
dropdb drops local database for project
dumpdata Dump data of an app in JSON format and store in the fixtures directory
grunt_build Execute grunt build for any cleanup that needs to happen before deployi...
gzip_assets GZIP files in the static directory and places files in the gzip directo...
loaddata load the data of an app in json format
npm usage: fab npm:<command>, <option>, <args>
publish DEFAULT: Compress, build and deploy project to Amazon S3.
reset delete all the deploy code
rs Start development server and grunt tasks. Optionally, specify port
scaffold Setup frontend management for Django project with yo, grunt and bower.
sh Run Django extensions shell
startapp Create django app
unbuild shortcut for django bakery unbuild command
Need help? Open an issue in: ISSUES
Want to improve the template? Fork the repo, add your changes and send a pull request.
Special thanks goes to Chase Davis for his initial work at developing our Django template for CIR. Also, this project's structure borrows many great ideas from Ben Welsh at the Los Angeles Times Datadesk and his Django Project Template.
The MIT License (MIT)
Copyright (c) '93 Til ... The Center for Investigative Reporting
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.