Kurian Benoy
Kurian Benoy

Reputation: 989

How to set virtualenvironent in Django so it redirects to proper Location

I am virtuallenvwrapper to isolate my Django Projects, but I can't point it to the required location on Workon my_project

How to fix this Issue ?

I reffered this site for installation:http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/

I am pretty sure this is a duplicate question ,but I couldn't find it anywhere.Please help Coders?

Upvotes: 0

Views: 243

Answers (2)

Kurian Benoy
Kurian Benoy

Reputation: 989

I am not using the vitualenvironment which is by default , but instead I use :virtualenv virtualenvwrapper

So at desired location I go there and make a virutal environment like:

 $ mkvirtualenv virtual

And to map it to my loacation So I can use any time inside the virtualenvironment I wrap to the required loacation like:

# Map project path to virtualenv
(virtual)$ setvirtualenvproject $VIRTUAL_ENV $(pwd)

I know @FlipperPA explained the concept really well.This is just a broad discription of what I did in my case

Upvotes: 0

FlipperPA
FlipperPA

Reputation: 14311

If you're looking to switch to a directory after activating a virtualenv with virtualenvwrapper, you can tie into the postactivate hook:

http://virtualenvwrapper.readthedocs.io/en/latest/scripts.html#postactivate

That should do the trick, and there's an example in the documentation.

For example, I keep my virtualenvs in my home directory, at /home/me/.virtualenvs/. I create a new one with mkvirtualenv project, and I now have a directory for it, /home/me/.virtualenvs/project. I can then edit /home/me/.virtualenvs/project/bin/postactivate and change the directory to where my project is.

Upvotes: 1

Related Questions