Entry Info

This entry was published on Thursday March 06, 2008.

It was tagged as:

Tags

Search

My blog feed

Running django-admin in PowerShell

Published Thursday March 06, 2008. Tags: Django

Continuing with my theme of tips, about what might seem like pretty much random stuff, today I am going to show how to setup your PowerShell profile to allow you to run python and django-admin in the active shell. Without this if you run django-admin using something like

python django-admin.py
then it will pop up a new command prompt window. Basically, you need to do two steps.

  1. Run PowerShell (as administrator in Windows Vista) and allow execution of local scripts without signing it:
    set-executionpolicy remotesigned
  2. Create UserProfile\Documents\WindowsPowershell\profile.ps1 (on Vista or UserProfile\My Documents\ in other versions) and put the following text in there, changing the paths as appropriate.
$env:PYTHONPATH="R:\django\packages\django-trunk"
$env:PATH=$env:PATH + ";D:\Programs\Python25\;R:\django\packages\django-trunk\django\bin"

function django-admin {python (gcm django-admin.py | resolve-path) $args}

If you are curious about the execution policy then checkout the very useful Getting Started document that came with PowerShell (look in your Start Menu).

2008–03-31, Update: I had an issue with the way I had posted this originally. I needed to add ’$args’ so that the arguments would be passed to the script.

Comments
Add new comment