Starting a Django Project
Published on April 3, 2016
Last Modified on April 5, 2016
- Install virtualenv and virtualenvwrapper
- create a directory for the project. This will be a subdirectory of venvs that was created when you installed virtualenvwrapper.
2 Make a virtual environment with mkproject
- Enter the environment with workon
- Install django using pip -- install django. Since you are in the virtual environment, you don't need sudo. Django will be installed in your account filetree -- not the root restricted folders.
- run django-admin startproject
create environment variables for sensitive information like username, password, secret key. Put this in the bin/activate file for the virtual environment. In the .virtualenvs//local/bin/postactivate put code to export names you wish not to keep in your settings.py. See below
add get_env_variables.py to the directory where settings.py is
- import get_env_variables to settings.py and use it to populate sensitive variables
- install git
- set up .gitignore
- put project in git repository
- push it to github
- go to work
your postactivate file:
# This hook is sourced after this virtualenv is activated.
The secret key can be obtained here