profile for joel goldstick at Stack Overflow, Q&A for professional and enthusiast programmers

JoelGoldstick.com

Starting a Django Project

Categories: Djangopythondeployment

Published on April 3, 2016

Last Modified on April 5, 2016

  1. Install virtualenv and virtualenvwrapper
  2. 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
  3. Enter the environment with workon
  4. 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.
  5. run django-admin startproject
  6. 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

  7. add get_env_variables.py to the directory where settings.py is

  8. import get_env_variables to settings.py and use it to populate sensitive variables
  9. install git
  10. set up .gitignore
  11. put project in git repository
  12. push it to github
  13. go to work

your postactivate file:

#!/bin/bash
# This hook is sourced after this virtualenv is activated.
EMAIL_HOST_USER=email@gmail.com
EMAIL_HOST_PASSWORD=password
SECRET_KEY=secret
export EMAIL_HOST_USER
export EMAIL_HOST_PASSWORD
export SECRET_KEY

The secret key can be obtained here