A cookiecutter template for Django.
Work-in-progress template for a complete django-based website with these intentions:
- as lightweight as possible
- looking at Django 1.7's startproject as a basis
- uses Bower as front-end package manager (and django-bower)
- installs jquery and bootstrap
- uses Gulp as task runner to automate less compilation
- should be easily deployable to procfile based hosting providers
- tries to use as many environment variables as possible
- I love dj-static by Kenneth Reitz - serving static files without a cdn
It uses a fixed set of versions as requirements, making sure that at least the dependencies that are listed, work well together.
Initial login for Django admin is whatever you set as username when cookiecutting (defaulting to "developer") and the password is "changeme".
Let's pretend you want to create a Django project called "sampleproject". Rather than using startproject and then editing the results to include your name, email, and various configuration issues that always get forgotten until the worst possible moment, get cookiecutter to do all the work.
First, get cookiecutter. Trust me, it's awesome:
$ pip install cookiecutter
Now run it against this repo, after creating a virtualenv:
$ mkvirtualenv <project-name> $ cookiecutter https://github.com/urga/cookiecutter-django-bootstrap.git $ setvirtualenvproject # This makes it easy to navigate to your project with 'cdproject'.
You'll be prompted for some questions, answer them, then it will create a Django project for you.
The structure used should look quite familiar:
Requirements
The requirements
folder contains a requirements file for each environment.
If you need to add a dependency please choose the right file.
Settings
The settings
folder contains a settings file for each environment.
If you take a look at base.py
, you'll see that it includes the module local.py
in the same folder. There you can override the local values.
The testing.py
module is loaded automatically after base.py
and local.py
every time you
run ./manage.py test
.
Django apps
Install your Django apps in the root of the project folder. This makes them easily transferable when the need arises.
Now, it's time to start writing some code!!!
This is what I want. It might not be what you want. Don't worry, you have options:
If you have differences in your preferred setup, I encourage you to fork this to create your own version. Once you have your fork working, let me know and I'll add it to a 'Similar Cookiecutter Templates' list here. It's up to you whether or not to rename your fork.
If you do rename your fork, I encourage you to submit it to the following places:
- cookiecutter so it gets listed in the README as a template.
- The cookiecutter grid on Django Packages.
I also accept pull requests on this, if they're small, atomic, and if they make my own project development experience better.