Kick-start your Django and AngularJS based web applications in minutes. Your project will be deployed on Heroku so you can focus on building apps and not infrastructure.
The project provides a minimal set of useful libraries to get you started as quickly as possible. Specific topics are covered by recipes.
What you get:
mkdir myproject && cd $_ wget -qO- https://raw.githubusercontent.com/djng/djng-init/master/djng.sh | bash
Make sure you like what's inside djng.sh.
Watch for changes in your client:
cd client grunt watch
Run the django development server:
source venv/bin/activate cd server python manage.py runserver_plus
If you want to execute your local development environment in the same manner as the remote environment you can use Foreman (it’s installed automatically by the Heroku Toolbelt) to run your Procfile-backed app.
Build your client:
cd client grunt build
server/.env and collect the static files:
cd server ./manage.py collectstatic --noinput
foreman start -e server/.env
This ensures that incompatibilities and hard to find bugs are caught before deploying to production and treats the application as a holistic unit instead of a series of individual commands working independently.
Add files, commit all your changes and push to heroku:
git add . git commit -m 'your changes' git push heroku master
This section covers the setup project process as done by djng-init, the interaction between the client and the server and the Heroku deployment.
Virtualenv is used to create an isolated Python environment for the Django server. The requirements are kept in requirements.txt and requirements_dev.txt:
virtualenv venv –no-site-packages source venv/bin/activate pip install -r requirements.txt pip install -r requirements_dev.txt
All environment specific configurations for Django are located in server/.env:
$ cat serve.env DJANGO_DEBUG=True DJANGO_SECRET=SUPER_SECRET DATABASE_URL=postgres://DBUSER:DBPW@localhost/DBNAME DJANGO_FROM_MAILfirstname.lastname@example.org DJANGO_ADMINS=<John Doe> email@example.com DJANGO_MANAGERS=<John Doe> firstname.lastname@example.org
This configuration is then used in the Django
This environment is conveniently loaded by
manage.py for local development. On Heroku this configuration is
managed by config vars. This project uses the handy
heroku-config plugin to manage the configuration.
All client dependencies are managed by npm and bower:
cd client npm install bower install
Note: As this is a SPA Django needs to catch all URLs handled by the client and return the index.html.
Therefore this URL pattern has to come last in your
urls.py as it would otherwise override all other url definitions.
This project uses heroku-buildpack-multi to run two buildpacks.
One is heroku-buildpack-webapp-client to build the client and
the other one is heroku-buildpack-python to run Django defined in
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-multi.git $ cat .buildpacks https://github.com/djng/heroku-buildpack-webapp-client.git https://github.com/heroku/heroku-buildpack-python.git