You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since virtualenvwrapper was mentioned earlier in the book (pg14, ch2), I feel that it would also be worth mentioning virtrtualenvwrapper's "add2virtualenv" path management command for setting PYTHONPATH. Mentioning this would probably be best in Chapter 5.2's TIP section on Page 39.
Many people get confused and only set DJANGO_SETTINGS_MODULE but not PYTHONPATH, and end up editing manage.py. Or they aren't aware of virtualenvwrapper's add2virtualenv command, which allows them to simply run add2virtualenv [dir-to-add] and the path info will show up in the _virtualenv_path_extensions.pth file located inside the sites-packages directory for the environment. We can can then verify this by running python -c 'import sys ; print sys.path'.
I got this to work with 2 scoops with: add2virtualenv /tmp/icecream.com/icecream_project/icecream_project/icecream_project
This dynamically adds a python path to ~/.virtualenvs/icecream.com/lib/python2.7/site-packages/_virtualenv_path_extensions.pth. I then set DJANGO_SETTINGS_MODULE permanently for the virtualenv with echo "export DJANGO_SETTINGS_MODULE=settings.local" >> $VIRTUAL_ENV/bin/postactivate
Since virtualenvwrapper was mentioned earlier in the book (pg14, ch2), I feel that it would also be worth mentioning virtrtualenvwrapper's "add2virtualenv" path management command for setting PYTHONPATH. Mentioning this would probably be best in Chapter 5.2's TIP section on Page 39.
Many people get confused and only set DJANGO_SETTINGS_MODULE but not PYTHONPATH, and end up editing manage.py. Or they aren't aware of virtualenvwrapper's add2virtualenv command, which allows them to simply run
add2virtualenv [dir-to-add]
and the path info will show up in the_virtualenv_path_extensions.pth
file located inside the sites-packages directory for the environment. We can can then verify this by runningpython -c 'import sys ; print sys.path'
.I got this to work with 2 scoops with:
add2virtualenv /tmp/icecream.com/icecream_project/icecream_project/icecream_project
This dynamically adds a python path to
~/.virtualenvs/icecream.com/lib/python2.7/site-packages/_virtualenv_path_extensions.pth
. I then set DJANGO_SETTINGS_MODULE permanently for the virtualenv withecho "export DJANGO_SETTINGS_MODULE=settings.local" >> $VIRTUAL_ENV/bin/postactivate
Reference: http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html#path-management
The text was updated successfully, but these errors were encountered: