My Django Setup

Posted Wednesday, April 7, 2010 at 2:56 p.m. by Chris Amico in Projects and Self-Indulgence about Django, Python and Ruby

I picked up my old MacBook from the Apple Store with a new, bigger, and spotless, hard drive, with a fresh install of Leopard.

Time consuming as it is to set up a computer from scratch, it's actually something I'd been meaning to do. The death of my old hard drive just forced me to do so sooner, and a little less gently than I might have liked. But it is nice starting from scratch.

With that in mind, I decided I should set up my development environment the Right Way: with code sandboxed as much as possible and projects organized in a sensible way. On my old setup, I'd created a "djcode" folder in my home directory, because at the time, all I was doing was Django. Two years later, that folder was cluttered with random test scripts (mostly Python), abandoned projects and apps, failed experiments and a lot of other junk.

You'd never know it looking at my desk at work (think grenade plus vending machine), but I actually do try to keep myself somewhat organized, at least digitally. So here's what my new arrangement looks like:

/home/chrisamico/
    /code
        /python
            /project1_ve
            /project2_ve
        /ruby
            /gems

Everything that looks like code, goes in code. Each language gets a folder. Each Python project gets a virtualenv. For now, since I've just started toying with Ruby, I'm still installing gems globally, but that feels messy. I may try to get Sandbox working soon, though.

From there, I try to make getting new projects up and running as painless as possible. Pip goes a long way in that regard. I keep a requirements file in my Python folder called django-requirements.txt that looks something like this:

ipython
docutils
PIL
django

Then it's just virtualenv --no-site-packages project_name and pip install -E project_name -r django-requirements.txt1 to glory.

And just in case something's wrong with this, I'll get to try again when I eventually upgrade to Snow Leopard.

So that's my setup. What about you, reader? How do (or don't) you organize yourself?



Comments:

apr 14, 2010 at 8:30 p.m. // John Tynan said:

Just put your suggestions to use. Got the requirements file going which is great!

One note that you may want to mention. On ubuntu, I needed to preface the use of pip with the following commands:

sudo apt-get install python-setuptools python-dev build-essential

sudo easy_install -U pip

Does that make sense to you?

apr 14, 2010 at 8:43 p.m. // Chris Amico said:

Hi John,

Yes, that makes sense. I tend to just install pip and virtualenv with sudo setup.py install, but I don't know that it makes any difference.

But once pip is installed, you shouldn't need easy_install at all.

Please use Markdown format, your real name and common decency. Remember that Google can always find the dumbest thing you've ever said.

Say it: