Django and Windows two things that may not get along each other very well.
I’ve been developing with Django and Windows over three years now and along the road I’ve developed few practical solutions for my team to make developers life a slightly easier.
My environment consists of few key parts: Python, setuptools, pip, virtualenv and TCC/LE.
Python should be obvious. Download and install it be sure to install 32 bit version. 64 bit version works but you will have great deal of troubles with 3rd party libs. I assume for the rest of the guide that you installed Python 2.7 under C:\Python27
After installing Python you should install TCC/LE. TCC/LE in short is replacement for CMD.EXE – a command prompt replacement. It has lot of nice features.
Now create your working directory, for the rest of the guide I assume that C:\django is working directory containing all virtual envs etc.
Under working directory create subdirectory config. In this directory create startup file for TCC/LE called tcstart.btm
@echo off rem Override system python binding to handle virtualenvironments set .py;.pyc=python.exe
Now create (copy) TCC/LE shortcut on desktop and rename it appropriately. Open Properties for shortcut and add to Target “C:\django\config\tcstart.btm”. You probably want to set Start in to something useful, like C:\django
First you need to install setuptools, just to make life a simpler:
Now open your newly create TCC prompt and type:
and then type:
c:\python27\scripts\pip install virtualenv
Now you’re ready to create your first virtualenv.
c:\python27\scripts\virtualenv my-proj-env –no-site-packages
Replace my-proj-env with suitable name for your virtualenv. Now final step is to activate your virtualenv. You have to do this every time you start TCC (or command) prompt. Activate enviroment with commands:
No your prompt should be prepended with name of the virtualenv, and should look something like:
Now you’re inside isolated Python environment and whatever you install using setup.py, pip or easy_install will be installed in this isolated environment. Note that you can’t use prebundled executable setup packages – they will be always installed in global site packages!
Now it’s time to install Django:
pip install django
After a while you should see that Django is downloaded and installed. You can try out command django-admin.py
If you got list of commands supported by django-admin – congratulations. You have very isolated working environment for your project.