Boston Python Workshop/Friday handout/Windows

About Django on Windows

 * These instructions should work for all versions of Windows from XP on to Windows 7.
 * You may need to login as Administrator, or give the Administrator password when installing some programs, depending on your Windows version and user settings.

Open a Command Prompt
http://www.wiki.devchix.com/index.php?title=Opening_a_command_prompt_window http://www.wiki.devchix.com/index.php?title=Recommended_setup_for_command-line_windows cls
 * Open a command prompt window, and keep it open along with your browser. Much of installing Python and using Django is typing commands and hitting &lt;enter&gt;.  Your experience using Rails on Windows greatly depends on your making friends with the command prompt window.
 * This is also called the command prompt, command window, command-line window, MS-DOS or DOS window.
 * Try these recommendations:
 * Tip: clear screen If you ever want to clear the &quot;output history&quot; to get a clear screen, type:
 * Tip: command history The command prompt window stores a &quot;command history.&quot; To view and re-run previous commands, use the &lt;up arrow&gt; and &lt;down arrow&gt; keys. You can also edit a previous command and run it--this is handy for long commands, or fixing mistakes.
 * Tip: copy and paste In the instructions below, where it says: &quot;In the command prompt type:&quot;, you can, much more easily, copy the command from this page, and right click in the menu bar or command prompt window, then click on &quot;Paste&quot;, then hit the &lt;enter&gt; key.

Install Python

 * Go to http://python.org/download/ and download the latest version of Python 2.7 (2.7.1 at the time of writing).


 * Test your Python install in the command prompt using the "-v" version flag:

\python27\python.exe -V

You should see something like Python 2.7.1 (r271:86832, ...) on win32 Type "help", "copyright", "credits" or "license" for more information. >>>


 * Type

exit

and press Enter, and you are back to the command prompt.

Install Git for Windows

 * Go to http://code.google.com/p/msysgit/ (aka GitBash)
 * Click on the top &quot;Downloads&quot; tab
 * Download the top .exe file link with the Summary something like &quot;Full installer for official Git 1.7.x.x&quot;
 * Run the install.
 * In the &quot;Select Components&quot; dialog, make sure the checkboxes &quot;Associate ... configuration files ...&quot; and &quot;Use a TrueType font ...&quot; are checked.

git
 * Important: In the &quot;Adjusting your PATH environment&quot; dialog, make sure &quot;Run Git from the Windows Command Prompt&quot; is selected.
 * In the &quot;Configuring the line ending conversions&quot; dialog, make sure &quot;Checkout Windows-style, commit Unix-style line endings&quot; is selected.
 * To run git, open Programs &gt; Git &gt; Git Bash
 * Then to test the Git install and see Git commands, in the command prompt type:

Configure Git
git config --global user.name  and: git config --global user.email 
 * Set up Git with your name and email to tag your code changes. In the command prompt type:

To have colored output, in the command prompt type each line followed by  : git config --global color.diff auto git config --global color.status auto git config --global color.branch auto
 * Tip: Colors

Install SQLite Manager

 * If you already have Firefox installed, verify that it is version 3.5.0 or greater. (Help -&gt; About Mozilla Firefox. The version number is right under the &quot;Firefox&quot; title.)
 * If you don't have Firefox installed, or it's an older version, install Firefox.
 * Once it's installed, open Firefox and go to Tools -&gt; Add-ons. At the top of the add-ons window, click &quot;Get Add-ons.&quot;
 * There will be search box directly underneath &quot;Get Add-ons&quot; that says &quot;Search All Add-ons.&quot; Enter &quot;SQLite&quot; (without the quotes) in the box and hit enter.
 * SQLite Manager should be the top result. Click &quot;Add to Firefox...&quot; (If SQLite Manager isn't in the results, check the spelling - SQLite only has one L. Also, check that you have at least Firefox 3.5.)
 * Wait for the countdown, then click &quot;Install Now.&quot;
 * In the Add-ons windows, click &quot;Restart Firefox.&quot;
 * Once Firefox restarts, the Add-ons window should say &quot;1 new add-on has been installed.&quot; Go to the Tools menu and verify that there is an option for SQLite Manager.

Install KomodoEdit
You need a text editor to do Python. If you already have a preferred text editor, such as vi, emacs, jedit, etc., you can skip this step. It must be a plain text editor and not something with styling like Microsoft Word.

When in doubt, use KomodoEdit.


 * Download KomodoEdit here.
 * Double-click to install.

Create an ssh public key
You'll need one of these to create your Heroku account in the next section.
 * Open up a new GitBash window.
 * (email should match git config setting)
 * Hit enter to accept default location for ssh key.
 * Hit enter to accept blank passphrase (if computer is shared with other people, as in a work laptop, you should create a passphrase). Hit enter again to accept blank passphrase (or enter passphrase again).
 * Output of ssh-keygen command
 * Your brand-new public key is now stored at.

Django

 * Open a new GitBash window.

curl -L http://www.djangoproject.com/download/1.2.5/tarball/  -o Django-1.2.5.tar.gz tar zxvf Django-1.2.5.tar.gz cd Django-1.2.5 python setup.py install

Verify you can create a new Django app
cd Desktop/django_projects /c/python27/scripts/django-admin.py startproject myproject cd myproject /c/python27/python manage.py runserver
 * Create a folder on the desktop called
 * Open a new GitBash window and type the following:
 * Both commands should provide no output.
 * Once that's finished, type the following in the Terminal window:
 * The first command should produce no output. The second command will put out a bunch of output, then just sit there until you cancel it (2 steps from now).
 * In your browser, go to http://localhost:8000/
 * Back in the Terminal window where you ran, type control-c to kill the server.

Cleanup
Ok, there is one more step. You won't be using the test project in the workshop; we just created it to make sure everything was working. You should delete it now to reduce confusion during the workshop. Don't worry about losing information; it just has the test project in it.


 * Drag the myproject folder (inside django_projects) to the Recycle Bin. Leave django_projects on the desktop.

Congratulations!
You have everything you need to write a Django web application in Python.

...on your machine.

The next set of directions help you use alwaysdata.com and its free-of-cost hosting.

Install PuTTY
PuTTY is a program we'll use to log in to the server where your Django code runs.


 * Go to the PuTTY download page
 * Choose the putty-0.60-installer.exe file.
 * Run the installer, and now you will find PuTTY in
 * Start->Programs->PuTTY