Giter Site home page Giter Site logo

twoscoops_test_app's Introduction

django-twoscoops-project

A project template for Django 1.5 with built-in support for Vagrant and Chef.

To use this project follow these steps:

  1. Create your working environment
  2. Install Django
  3. Create the new project using the django-two-scoops template
  4. Install additional dependencies
  5. Use the Django admin to create the project

note: these instructions show creation of a project called "icecream". You should replace this name with the actual name of your project.

Working Environment

This project template has been modified for developers using isolated virtual machines managed by vagrant. It is still recommended that you install virtualenv on the host machine to isolate your installation of django. We still need django on the host machine to create the new project from this template.

Virtual Box

https://www.virtualbox.org/wiki/Downloads

Vagrant

Vagrant (1.2+) - http://vagrantup.com/downloads

Vagrant Omnibus

vagrant-omnibus is a plugin that ensures the appropriate version of chef get installed. Once you have installed vagrant, run this command:

$ vagrant plugin install vagrant-omnibus

Vagrant Berkshelf

Install the berkshelf gem:

$ gem install berkshelf

vagrant-berkshelf is a plugin that ensures that all cookbook dependancies are dealt with. To install vagrant-berkshelf, run this command:

$ vagrant plugin install vagrant-berkshelf

Vagrant AWS

If you want to deploy using the AWS provider you will first need to install the plugin by running this command:

$ vagrant plugin install vagrant-aws

Local Virtualenv

First, make sure you are using virtualenv (http://www.virtualenv.org). Once that's installed, create your virtualenv:

$ virtualenv --distribute icecream

You will also need to ensure that the virtualenv has the project directory added to the path. Adding the project directory will allow django-admin.py to be able to change settings using the --settings flag.

Virtualenv with virtualenvwrapper

In Linux and Mac OSX, you can install virtualenvwrapper (http://virtualenvwrapper.readthedocs.org/en/latest/), which will take care of managing your virtual environments and adding the project path to the site-directory for you:

$ mkdir icecream
$ mkvirtualenv -a icecream icecream-dev
$ cd icecream && add2virtualenv `pwd`

Windows

In Windows, or if you're not comfortable using the command line, you will need to add a .pth file to the site-packages of your virtualenv. If you have been following the book's example for the virtualenv directory (pg. 12), then you will need to add a python pathfile named _virtualenv_path_extensions.pth to the site-packages. If you have been following the book, then your virtualenv folder will be something like:

`~/.virtualenvs/icecream/lib/python2.7/site-directory/`

In the pathfile, you will want to include the following code (from virtualenvwrapper):

import sys; sys.__plen = len(sys.path) /home/<youruser>/icecream/icecream/ import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

Installing Django

To install Django in the new virtual environment, run the following command:

$ pip install django

Creating your project

To create a new Django project called 'icecream' using django-twoscoops-project, run the following command:

$ django-admin.py startproject --template=https://github.com/jwmarshall/django-twoscoops-project/archive/develop.zip --name=Vagrantfile --extension=py,rst,html icecream

Creating your virtual machine

To create a new virtual machine running your project, run the following command:

$ cd icecream
$ vagrant up

Creating a new virtual machine for the first time can take several minutes. Once completed you can login by running the following command:

$ vagrant ssh

Your project is already running too! Visit the following URL:

http://localhost:8080

You can login to the django admin with the following username and password:

user: vagrant
pass: vagrant

All of the project files are all kept on your host computer and mounted inside the virtual machine. Move into your new project directory and start coding:

$ cd /vagrant/icecream

Installation of Dependencies

All dependancies should be satisfied by the time vagrant up completes.

Manually installing dependencies:

In development:

$ pip install -r requirements/local.txt

For production:

$ pip install -r requirements.txt

note: We install production requirements this way because many Platforms as a Services expect a requirements.txt file in the root of projects.

Acknowledgements

  • Many thanks to Randall Degges for the inspiration to write the book and django-skel.
  • All of the contributors to this project.

twoscoops_test_app's People

Watchers

Jonathon W. Marshall avatar James Cloos avatar

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.