Skip to content

Instantly share code, notes, and snippets.

View PCreations's full-sized avatar

Pierre Criulanscy PCreations

View GitHub Profile
pip install virtualenv
pip install virtualenvwrapper
which python3 #will output the python3 path such as /usr/bin/python3
mkvirtualenv --python=/usr/bin/python3 my_new_project
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4'
New python executable in my_new_project/bin/python3.4
Also creating executable in my_new_project/bin/python
Installing setuptools, pip...done.
(my_new_project)MacBook-Air-de-Pierre:Repositories Pierre$
cd /Users/Pierre/Repositories/Perso
mkdir trackr
cd trackr
trackr
└── trackr
├── manage.py
└── trackr
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py
trackr
├── README.rst
├── docs
├── requirements
└── trackr
├── manage.py
└── trackr
├── __init__.py
├── settings.py
├── urls.py
trackr
├── README.rst
├── docs
├── requirements
│   ├── base.txt
│   ├── local.txt
│   ├── production.txt
│   └── test.txt
└── trackr
├── manage.py
import os
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
import os
from django.core.exceptions import ImproperlyConfigured
def get_env_variable(var_name):
""" Gets the environment variable or returns exception. """
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the {} environment variable".format(var_name)
CONFIG_ROOT = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.abspath(os.path.join(CONFIG_ROOT, os.pardir))