Giter VIP home page Giter VIP logo

djng's Introduction

djng

Join the chat at https://gitter.im/djng/djng

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:

Prerequisites

Bootstrap your project

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.

Developing

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

Developing locally with Foreman

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

Set DJANGO_DEBUG=False in server/.env and collect the static files:

cd server
./manage.py collectstatic --noinput

Run foreman:

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.

Deploying

Add files, commit all your changes and push to heroku:

git add .
git commit -m 'your changes'
git push heroku master

How it works

This section covers the setup project process as done by djng-init, the interaction between the client and the server and the Heroku deployment.

Environment

Django server

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
[email protected]
DJANGO_ADMINS=<John Doe> [email protected]
DJANGO_MANAGERS=<John Doe> [email protected]

This configuration is then used in the Django settings.py.

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.

AngularJs Client

All client dependencies are managed by npm and bower:

cd client
npm install
bower install

Serving static assets

All static assets are served by WhiteNoise in production to keep things simple. During local development the files are served by the django.contrib.staticfile app directly from the client directory.

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.

Heroku Deployment

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 .buildpacks:

$ 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

djng's People

Contributors

aeby avatar bryant1410 avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

djng's Issues

Celery Support

I'm struggling to add a celery worker to the Procfile with this file structure. The '--pythonpath core' parameter isn't supported by celery. Has anyone found a solution to this?

Explain foreman

Mimic the deployment process locally using grunt build, debug = False, collect static and foreman

A suggestion for djng.sh

Hey!
I have a suggestion for your (djng.sh)[https://raw.githubusercontent.com/djng/djng-init/master/djng.sh], it would be great if we check the prerequisites before downloading the project. Because if a user doesn't have a dependency he/she will have to install it and redownload the project adding to extra data consumption.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.