Because Portable Python is a “portable” application, it is not registered in Windows registry and your operating system does not know where python executable is located. Because of this, you can not simply type my_script.py on the command prompt and expect Windows to know what to do with that command. In the same way, you can not use django-admin.py without specifying Python executable that should be used to interpret this Python script file. Correct way to execute Python scripts in Portable Python is to use Python-Portable.exe like explained in Hello World

Check your installation

In case that we want to see version of django that is installed in Portable Python, we can use command prompt and execute Python-Portable.exe in direct command execution mode:

1
Python-Portable.exe -c "import django; print(django.get_version());raw_input('Press <ENTER> to continue')"

Python built-in function raw_input is used in this case to get input from the user and to pause execution at the end of the script until user presses enter key. Without this function, command prompt would quickly flash and disappear and we would not have a chance to see output of the print(django.get_version()) command.

Create a new project

Creating a new Django project is exactly the same like explained in Django tutorials: django-admin.py startproject mysite, only like explained above we need to pass correct paths for Python executable and django-admin.py. Lets assume that our project will live in C:\Temp, by using command line we navigate to folder where we will create our project (in this case C:\Temp) and then create a new project called “mysite”:

1
c:\Temp>"[PP root folder]\Python-Portable.exe" "[PP root folder]\App\Scripts\django-admin.py" startproject mysite

Where [PP root folder] is the full path to our Portable Python installation, e.g. H:\Portable Python 2.7.6.1.

This will create a folder called “mysite” in C:\Temp that holds skeleton of our first Django project. To start development server and see this skeleton application working, we need to navigate to folder “mysite” and start development server:

1
2
3
c:\Temp>cd mysite

c:\Temp\mysite>"[PP root folder]\Python-Portable.exe" manage.py runserver

This will validate models in our application and start development server - after couple of seconds, console window will open with text similar to this

1
2
3
4
5
6
7
Validating models...

0 errors found
April 19, 2014 - 23:31:37
Django version 1.6.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

To see this development site in action, navigate with your internet browser to http://127.0.0.1:8000/

For more details on how to build Django enabled applications please refer to Django tutorial.