Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend add2virtualenv: Page 39, Chapter 5.2, TIP section #63

Open
rkulla opened this issue Apr 6, 2014 · 0 comments
Open

Recommend add2virtualenv: Page 39, Chapter 5.2, TIP section #63

rkulla opened this issue Apr 6, 2014 · 0 comments

Comments

@rkulla
Copy link

rkulla commented Apr 6, 2014

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

Reference: http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html#path-management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants