I am new to django development (I was working with MS and Oracle/Java stack). I now how important it is to prepare your dev environment right. I have web server with some small django project I am going to expand, pycharm IDE (checked possibilities and chosen this one) on windows. Project is not in any version control but I am going to put it into git later.
My question is – how to configure environment and import my project into it? Is it possible to put my devproject into virtual machine and edit it in pycharm from windows (tried but didnt know how to do it) or do I have to install django on windows? I am a little reluctant to install all this staff on my workstation but it may be necessary. Is it possible to install django modules only for this project and not pollute my global python environment?
This may be obvious for regular django devs but I am little lost.
Since I wrote this answer, PyCharm has greatly expanded their support for virtual environments; and now you can create virtual environments when starting projects.
For more information, see PyCharm online documentation.
I use PyCharm on Windows at work, and this process works for me (since PyCharm doesn’t support virtual env in the project creation stage). You have to put the django libraries on your development machine for the code hinting and method signatures to work.
To do this, you need to first install setuptools and then install pip in your system python.
For New Projects
First create your virtual environment, this will avoid polluting your base python install.
D:\>virtualenv --no-site-packages myenvNew python executable in myenv\Scripts\python.exeInstalling setuptools................done.Installing pip...................done.Next, switch into this env:
D:\>myenv\Scripts\activate(myenv)D:\>Install django into this environment:
pip install django, and any other libs you might need for this project.Run
PyCharmandFile > New ProjectGive your project a name and select
Django projectfrom the Project type drop downOn the next screen, click the button to the right of the python interpreter, and browse to your virtual environment, and select the directory with the
python.exefile.Now your project is setup to only use the virtualenv python. Once you are done developing, you can freeze your install and replicate it on your testing environment.
Once you are done, you can simply delete the directory
myenvto remove the project-specific libs.